[Tutor] Python Programming exercise

Christian Witts cwitts at compuscan.co.za
Wed Jul 1 08:48:16 CEST 2009


Daniel Sato 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
>
> -- 
> Daniel Sato
> http://www.danielsato.com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>   
Indent line 9, because Python is indentation sensitive and does not use 
braces for code blocks you have to make sure it is all in-line.  Also 
line 8 should have a colon at the end of it.  My memory is a bit fuzzy 
on whether or not raw_input() captures the new-line character as well, 
so if it doesn't match still you will need to do a .strip() on your guess.
Hope that helps.

-- 
Kind Regards,
Christian Witts




More information about the Tutor mailing list