views:

93

answers:

4

question1=input("What is" + name+"'s" + "favorite number?")
question2=input("What is" + name+"'s" + "favorite Letter?")
question3=input("What is" + name+"'s" + "favorite age?")
question4=input("What is" + name+"'s" + "favorite video system?")
question5=input("What is" + name+"'s" + "favorite color?")
question6=input("What is" + name+"'s" + "favorite type of music?")

q=answer1=input("favorite number")
w=answer2=input("favorite letter")
e=answer3=input("favorite age")
r=answer4=input("favorite video system")
t=answer5=input("favorite color")
y=answer6=input("favorite type of music")

end=("congrats you know your friend")


print "How Well Do You Know Your Friend?"

input("Your Name")=name
print "Please answer following questions"
answer1
answer2
answer3
answer4
answer5
answer6

print "Pass to Friend"
print "Please answer following questions"

question1

if question1== q:
    question2

if question2== w:        
    question3

if question3== e:
    question4

if question4== r:
    question5

if question5== t:
    question6

if question6== y:
    print end

print "goodbye"
+2  A: 

The first problem is that you have the line (20):

input("Your Name")=name

Which is probably a flip-flop of what you want:

name = input("Your Name")

Since you want to assign the user input to the local variable 'name'. The exact error you're getting says that the value of 'name' cannot be assigned to a function call input(...) (since function calls are immutable).

Beyond that, you'll also probably want to change all the input(...) function calls to raw_input(...).

mjschultz
He/she might be on Python 3 where `input()` is the new `raw_input()`.
Tim Pietzcker
@Tim, no, since sie's using `print` as a statement, not a function.
Alex Martelli
@Alex: Oh, right.
Tim Pietzcker
+1  A: 

Well, you are trying to assign to a function call here:

input("Your Name")=name

Also take a look at the documentation for input():

Warning This function is not safe from user errors! It expects a valid Python expression as input; if the input is not syntactically valid, a SyntaxError will be raised. Other exceptions may be raised if there is an error during evaluation. (On the other hand, sometimes this is exactly what you need when writing a quick script for expert use.)

And:

Consider using the raw_input() function for general input from users.

Following this hint and fixing the order you get to:

name = raw_input("Your name: ")
Georg Fritzsche
+1  A: 

Aside from the obvious error that you're assigning a function to a name (an undefined one, too) as other answerers have already pointed out, I think you're misunderstanding how assignments of functions work.

When you write

answer1=input("favorite number")

and later

print "Please answer following questions"
answer1

it looks to me like you are expecting answer1 to be a shortcut for calling input("favorite number"). This is not the case.

What you wrote means: Execute input("favorite number") and store the result (which is the term the user entered) in variable answer1 which will then hold a string.

So if you later write answer in your program, it will do nothing (at least nothing visible - the string is evaluated, there is nothing else to do with it so the interpreter shrugs and moves on).

You can assign a function to a variable by saying a=input and then later calling a("Please enter something! "), but this is just creating a new name for the function.

Tim Pietzcker
A: 

Check the tutorial that you are using ...

input("Your Name")=name should be name = input("Your Name")

John Machin