Re: Basic question from pure beginner

2009-07-01 Thread alex23
Dennis Lee Bieber wrote: >         There is also the getpass module to play with! I don't think I've ever seen getpass, so thanks for pointing that out. Unfortunately, it wouldn't have helped the OP understand why his original code wasn't working ;) -- http://mail.python.org/mailman/listinfo/pyt

Re: Basic question from pure beginner

2009-07-01 Thread alex23
On Jul 2, 3:47 am, Scott David Daniels wrote: > And even simpler: >      PASSWORD = "qwerty" >      MAXRETRY = 3 >      for attempt in range(MAXRETRY): >          if raw_input('Enter your password: ') == PASSWORD: >              print 'Password confirmed' >              break # this exits the for

Re: Basic question from pure beginner

2009-07-01 Thread Scott David Daniels
Charles Yeomans wrote: Let me offer a bit of editing Finally, I'd remove correct_password_given from the loop test, and replace it with a break statement when the correct password is entered. password = "qwerty" correct_password_given = False attemptcount = 0 MaxAttempts = 3 while attemptc

Re: Basic question from pure beginner

2009-07-01 Thread Charles Yeomans
Let me offer a bit of editing. First, using the condition count != 3 is perhaps risky. A mistake or a change in logic in the loop body might result in an infinite loop. So instead I suggest while count < 3... Second, I'd suggest storing the value 3 in a variable with a name that descri

Re: Basic question from pure beginner

2009-07-01 Thread MRAB
sato.ph...@gmail.com 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#

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Scott David Daniels a écrit : (snip) And even simpler: PASSWORD = "qwerty" MAXRETRY = 3 for attempt in range(MAXRETRY): if raw_input('Enter your password: ') == PASSWORD: print 'Password confirmed' break # this exits the for loop print 'Access

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Charles Yeomans a écrit : Please don't top-post (not corrected) Let me offer a bit of editing. First, using the condition count != 3 is perhaps risky. A mistake or a change in logic in the loop body might result in an infinite loop. So instead I suggest while count < 3... Second, I'd su

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
sato.ph...@gmail.com a écrit : Thank you for all of the help. With your assistance and help from the Python Tutor mailing list I was able to come up with the following code: password = "qwerty" correct_password_given = False guess = "0" You could just use None here: guess=None count = 0

Re: Basic question from pure beginner

2009-07-01 Thread sato.ph...@gmail.com
Thank you for all of the help. With your assistance and help from the Python Tutor mailing list I was able to come up with the following code: password = "qwerty" correct_password_given = False guess = "0" count = 0 while count != 3 and not correct_password_given : guess = raw_input("Enter you

Re: Basic question from pure beginner

2009-07-01 Thread alex23
On Jul 1, 3:38 pm, "sato.ph...@gmail.com" wrote: > 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.   Not with the code you pasted, you haven't. There's a missing colon on line 7 & line 9 isn'

Re: Basic question from pure beginner

2009-07-01 Thread Peter Otten
sato.ph...@gmail.com 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_S

Basic question from pure beginner

2009-07-01 Thread sato.ph...@gmail.com
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