[Tutor] embedding an if
peter hodgson
py at humnet.ucla.edu
Mon Mar 29 13:39:16 EST 2004
hello; 2.3 on a gentoo box;
tutorial assignment; what am i doing wrong? thanks
#Modify the password guessing program to keep track of how many times
# the user has entered the password wrong. If it is more than 3 times,
# print "you're screwed, buddy!", or something like that;
passwd = "foobar" #a dummy passwd
count = 3
current_count = 0
while passwd != "unicorn":
current_count = current_count + 1
passwd = raw_input("Passwd: ")
if current_count < count:
print "no, stupid! try again;"
else print "three times, you're out!"
print "welcome in"
#without 'count': keep asking for password until the jerk gets it right;
#with 'count': he only gets three chances;
More information about the Tutor
mailing list