Hey all,
Sorry for the bother, thanks for the help.
I'm trying to write a password guessing program to keep track of
how many times the user has entered the password wrong.
If it is more than 3 times, print ``That must have been complicated.''
Following is what I got. If I type "unicorn" it goes s
Hi Gary,
In a while loop, you could looping until the while condition is no longer true.
So your one -
while password != "unicorn"
So while password isn't unicorn, your condition is True, so your while
loop will keep looping until the password equals 'unicorn'
After your 3rd mistake, the if
o "unicorn" until the end
of time.
Thanks,
Ryan
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Monday, April 11, 2005 2:55 PM
To: tutor@python.org
Subject: [Tutor] Cell Bio Newbie Here
Hey all,
Sorry for the bother,
[EMAIL PROTECTED] said unto the world upon 2005-04-11 14:54:
Hey all,
Sorry for the bother, thanks for the help.
I'm trying to write a password guessing program to keep track of
how many times the user has entered the password wrong.
If it is more than 3 times, print ``That must have been complicat
ot; if password="unicorn": print "Try again Later" else: print "Welcome in"
Here you will lock your prog when the user fails 3 times and will print your line once and then will jump to Try Again later and it will finish
Hope that help
Alberto Troiano said unto the world upon 2005-04-11 16:09:
Hey Gary
password="foobar"
###
the variable password has to be here because you are referiencing before the
assignment inside the while sentence. You can also set it to password="" and
still will work because you have to tell (in this
Ok, it's a logic error in the while loop. Starting at the beginning: you
can't compare the value of "password" until the user inputs the value, which
is why it's requiring you to put password = "foobar" at the top. Otherwise,
password has no value, and as far as the interpreter is concerned, i
gt; >CC: [EMAIL PROTECTED], tutor@python.org >Subject: Re: [Tutor] Cell Bio Newbie Here >Date: Mon, 11 Apr 2005 16:45:55 -0400 > >Alberto Troiano said unto the world upon 2005-04-11 16:09: >>Hey Gary >> >>password="foobar" >> >>### >> >
AIL PROTECTED], tutor@python.org >Subject: Re: [Tutor] Cell Bio Newbie Here >Date: Mon, 11 Apr 2005 16:45:55 -0400 > >Alberto Troiano said unto the world upon 2005-04-11 16:09: >>Hey Gary >> >>password="foobar" >> >>### >> >>the variab
Alberto Troiano said unto the world upon 2005-04-11 17:43:
Hi Brian
Thanks for correcting me about the variable and reserved word differences (just
for the record the problem is that my english is not so good, you see I'm from
Bolivia so pardon my francôis :P)
Hi Alberto,
I wouldn't have known y
Ok, it's a logic error in the while loop. Starting at the beginning: you
can't compare the value of "password" until the user inputs the value,
which
is why it's requiring you to put password = "foobar" at the top.
Otherwise,
password has no value, and as far as the interpreter is concerned, it
RegardsAlberto
Gaucho>From: Brian van den Broek <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Cell Bio Newbie Here >Date: Mon, 11 Apr 2005 19:11:50 -0400 > >Alberto Troiano said unto the world upon 2005-04-11
The reason you are looping forever is because you are not resetting
current_count to zero.
Let's step through your logic, assume that current_count = 2
- you enter into the if part of your logic
- prompt the user for a password
- user enters a password, let's assume it's not unicorn, and you stor
At 02:02 PM 4/11/2005, you wrote:
Send Tutor mailing list submissions to
tutor@python.org
Hey all,
Sorry for the bother, thanks for the help
#first of all, why does this have to be here?
password="foobar"
count=3
current_count=0
while password !="unicorn":
if current_count
print "
14 matches
Mail list logo