0
the type none
hello i have a problem why this code print 1? foo = print() if foo == None: print(1) else: print(2) i have a error in the compilation because the problem start in foo = print() and the message is SyntaxError: invalid syntax why i have that error?
2 Respostas
+ 4
Do instead
foo = input()
if foo is None:
print("1")
else:
print("2")
If you are using python 2, use raw_input() instead.
0
This is because you can't set a variable to be equal to print(), as that function does not return anything.