Basic question from pure beginner
bdesth.quelquechose at free.quelquepart.fr
Wed Jul 1 12:43:44 EDT 2009
Charles Yeomans a écrit :
<ot>Please don't top-post (not corrected)</ot>
> 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
> describes it.
Pretty sensible suggestion, but then:
> MaxAttempts = 3
follow conventions instead :
MAX_ATTEMPS = 3
> Finally, I'd remove correct_password_given from the loop test, and
> replace it with a break statement when the correct password is entered.
Then using a while loop and manually incrementing a counter is a waste
of time - using a for loop would be simplier and less error-prone.
More information about the Python-list