I need help figuring out how to fix this code.

Brian desertgarden at netscape.com
Wed Jun 29 13:01:32 EDT 2005


Hi Nathan,

Please see my comments listed below.

Nathan Pinno wrote:

>   print "Program Author: Nathan Pinno"
>   print "ID# 2413448"
>   print
>   print "Program 3 - Loops and IF Conditions"
>   print
>   password = raw_input("Type in the password, please: ")
>   while password != "hello":
>       print "Incorrect password!"


At this point, you need to add the following statement again:
     password = raw_input("Type in the password, please: ")

Otherwise, it just keeps stating "Incorrect password!" forever without 
giving the user the ability to re-enter another password attemp / try.


>   print "Welcome to the second half of the program!"
>   name = raw_input("What is your name, please? ")
>       if name == "Nathan":
>           print "What a great name!"
>       elif name == ["Madonna", "Cher"]:
>           print "May I have your autograph please!"
>       else
>           print name,", that's a nice name!"


Remove the tab indentions in front of the "if", "elif", and "else" 
statements.  This will cause an error in your program.  The only time 
that you need to indent is the code following the if statements.

if name == "Steven":
	print "Then I indent this code here."
else:
	print "This is another coded statement here."


>   Thanks,
>   Nathan Pinno


You're welcome, Nathan!

Hope this helps (HTH),

Brian
---



More information about the Python-list mailing list