[Tutor] Python Programming exercise
bgailer at gmail.com
Wed Jul 1 17:00:45 CEST 2009
Daniel Sato wrote:
> I have been going through some Python Programming exercises while
> following the MIT OpenCourseWare Intro to CS syllabus and am having
> some trouble with the first "If" exercise listed on this page:
> I have been able to make the module quit after entering a password
> three times, but can't get it to quit right away after the correct one
> is entered. I know this is really basic, please forgive me. I have
> no programming experience and have just started going through these
> My code is here:
When the code is that small please just put it in the body of your post.
Save pastebin for (IMHO) anything over say 60 lines.
password = "qwerty"
guess = "0"
count = 0
while count != 3:
guess = raw_input("Enter your password: ")
guess = str(guess)
if guess != password
print "Access Denied"
count = count + 1
print "Password Confirmed"
2 ways - either
while count != 3 and guess != password:
11. print "Password Confirmed"
Chapel Hill NC
More information about the Tutor