1. Pay more attention to what ends an if statement (:) also watch your
indentation. 

2.  Code is better than my commentary. This works the way you want it to
work.

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       
        else:
                print "Password Confirmed"
                break

Robert Berman


On Tue, 2009-06-30 at 19:53 -0700, 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:
> 
> http://en.wikibooks.org/wiki/Python_Programming/Conditional_Statements#If_Exercises
> 
> 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
> tutorials.
> 
> My code is here:
> 
> http://python.pastebin.com/m6036b52e
> 
> -- 
> Daniel Sato
> http://www.danielsato.com
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to