Thread: I need help!!!!
View Single Post
  #3 (permalink)  
Old 10-15-2007, 06:58 PM
hds272 hds272 is offline
Newbie
 
Join Date: Oct 2007
Posts: 4
Rep Power: 0
hds272 is on a distinguished road
Default

Quote:
Originally Posted by v0id View Post
First of all; the indents aren't showing, because you're not using the code-tags. Use them in your further posts.

There is four major problems in the code you posted.
1. input() is used for integers, and such, while raw_input() is used for text-input. Just think of it like: input() for numbers and raw_input() for strings.
2. Instead of using the compare-operator, ==, you're using the assignment operator, =. There's a big difference between these operators.
3. When your tries to compare in most of your if-statements, you're forgetting the double-quotes. These are necessary, or the interpreter will see them as variables - and you haven't declared those variable - which result in: error(s)
4. Languages like C++ are using curly brackets for statements, and such, while Python is using colons and indents. So, you need a ':' right after all the places where you're using a statement, e.g. if-statements.

Look at this [corrected] code:
Code:
print "Please enter the first name of a family member."
print "The choices are John, Jane, Jim, and scruffle."

text = raw_input()

if text == "John":
    print "Hello, John"
elif text == "Jane":
    print "Hello, Jane"
elif text == "Jim":
    print "Hello, Jim"
elif text == "Scruffle":
    print "RUFF!!"
else:
    print "I don't know you, sorry!"
Thanks so much, but could you please clarify on #3?



Also with my revised code:
Code:
#small program to introduce members of the family
print "Please enter the first name of a family member.", " ", "the choices are john, jane, jim, and scruffle."
text = raw_input()
if text == "john"
        print "this is john":
elif text == jane
	print "this is jane":
elif text == jim
	print "this is jim":
elif text == scruffle
	print "RUFF!!":
else: 
	print "Please retype!"
I get this error:

Last edited by hds272; 10-15-2007 at 10:00 PM.
Reply With Quote