0

I think I'm almost there on this function I'm trying to write, but just can't get the last piece. I have to write a function that will return "True" if the number 7 appears in a string exactly 3 times, and "False" if it's more or less. I can't figure out how to get it so it'll search for non-consecutive 7's. Any hints?

def luckySevens(aStr):
    if "777" in aStr:
        return True
    else:
        return False


#You can use these lines to test your code. They are not used
#for grading, so feel free to change them.

testStringTrue = "happy777bday"
print(testStringTrue, luckySevens(testStringTrue))
testStringFalse1 = "happy77bday"
print(testStringFalse1, luckySevens(testStringFalse1))
testStringFalse2 = "h777app7y77bday"
print(testStringFalse2, luckySevens(testStringFalse2))
Katie Stearns
  • 55
  • 1
  • 1
  • 7

0 Answers0