Basic question from pure beginner
MRAB
python at mrabarnett.plus.com
Wed Jul 1 12:18:24 EDT 2009
sato.photo at 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#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
>
raw_input() returns a string, so you don't need "guess = str(guess)".
The 'if' line should end with a colon.
Incrementing the count should probably be after the 'if' statement.
You can leave a loop prematurely with the 'break' statement.
More information about the Python-list
mailing list