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?

12th Jan 2018, 1:00 AM
Daniel H. Cortez
Daniel H. Cortez - avatar
2 odpowiedzi
+ 4
Do instead foo = input() if foo is None: print("1") else: print("2") If you are using python 2, use raw_input() instead.
12th Jan 2018, 7:00 AM
Paulera
0
This is because you can't set a variable to be equal to print(), as that function does not return anything.
12th Jan 2018, 3:48 AM
Faisal
Faisal - avatar