+ 1
How do you use inputs and if variables?
whenever I put something like "if (x) == 2" I always get an error, can anyone explain? My code is: Stuff = [(x),(y),(z)] x = input("Enter a number:\n") y = input("Enter another:\n") z = input("Enter one more please:\n") if (x) = 3 print ("Nice")
4 Answers
+ 1
I see additional mistakes to the one corrected by the other users.
Remove the circle brackets. You are unintentionally making tuples.
You tried to make a list with undefined variables.
input() should be int(input ()) in order to convert the received value to an integer and compare it to another integer. Or you could compare x to "3" instead if you will not use x for arithmetic.
Your code should be:
x = int (input ("Enter a number \n"))
y = int (input ("Enter another \n"))
z = int (input ("Enter one more please\n"))
if x == 3:
print ("Nice")
0
it should be
if x = 3:
print ("nice")
0
it should be
if x == 3:
print("nice")
0
A single equal to " = " is an a assignment operator, and does compare left hand side with right hand side, instead it assigns 3 to x. If you want to compare lhs and rhs, always use the comparison operator ==