+ 2

i wanna write program "42" (Python) but i cant

x=0 x=x+1 if x=42: print ("answer")

14th Jan 2019, 3:37 AM
tq tally
2 odpowiedzi
+ 12
use '==' for comparison x = 42 assigns 42 to x x == 42 returns True if x is equal to 42
14th Jan 2019, 4:31 AM
Mert Yazıcı
Mert Yazıcı - avatar
+ 1
You can also do this if x is 42: print (answer)
15th Jan 2019, 5:06 AM
Dan Rhamba
Dan Rhamba - avatar