I’m trying to write a simple “password” program in Python that allows 3 attempts at “logging in” with a recursive function. I can’t figure out why it’s not working though… (And yes, Jurassic Park inspired)
def magicWord(count):
int(count)
answer = raw_input("What is the password? ")
if answer == 'lucas':
print 'ACESS GRANTED'
else:
count =+ 1
if count > 2:
while count > 2:
count+=1
print "na na na you didn\'t say the magic word. "
else:
magicWord(count)
magicWord(0)
You were very close. There were just a couple minor fix-ups:
Here’s a sample session: