Answer:
Here is the Python program:
 def lucky_sevens(a_string):  # function to return true if exactly 3 sevens
    counter = 0  # counts the number of times 7 occurs in the a_string
    for i in a_string:  # loops through the a_string
        if i == "7":  # if 7 occurs in the a_string
            counter = counter + 1  #counter increases by 1 every time 7 occurs
    if counter == 3:  #if 7 occurs exactly 3 times in a_string
        return True  #returns true
    else:  # 7 occurs less or more than 3 times in a_string
        return False  # returns false
 #tests the function lucky_sevens with different inputs      
print(lucky_sevens("happy777bday"))
print(lucky_sevens("h7app7ybd7ay"))
print(lucky_sevens("happy77bday"))
print(lucky_sevens("h777appy777bday"))  
  
Explanation:
This program has a method lucky_sevens that has a parameter a_string which contains a string of characters. The counter variable stores the number of times 7 occurs in the string. The loop has variable i that works like an index and moves through the entire string looking for 7 in the a_string. If element at i-th index is 7 then the counter variable increments by 1. It increments by 1 at every occurrence of 7. Then if condition checks if the value of count is equal to 3. Which means that 7 occurred 3 times in the a_string. If the condition is true then True is displayed otherwise False is displayed on output screen.