I got stuck on a homework problem where I need to write a function that takes in one parameter and returns True if there are exactly three 7's in a string. If there are less than three or more than three '7's, the function should return False.
def lucky_seven(a_string):
if "7" in a_string:
return True
else:
return False
print(lucky_seven("happy777bday"))
print(lucky_seven("happy77bday"))
print(lucky_seven("h7app7ybd7ay"))
The result should be True, False, True. I got I to work where only one 7 is in a string. Appreciate if anyone can point me into the right direction.