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
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
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
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
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#
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
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
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
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
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'
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
11 matches
Mail list logo