+ 1

Can someone assist, what's wrong with this code? I'm a rookie in python

dinner=input("What did you eat") if dinner=food: print("Keep on eating") else: print("The program has ended")

22nd Jun 2017, 12:34 PM
Sizwe Khumalo
Sizwe Khumalo - avatar
4 Antworten
+ 5
if dinner == "food": = is assignment operator == is used to check equality
22nd Jun 2017, 12:37 PM
Da' BO$
Da' BO$ - avatar
+ 2
YOU SHOULD USE == IN THE PLACE OF = =(is equal to) is used for assigning the values to a variable and == is used to compare the value of variables ^°,,°^
22nd Jun 2017, 1:11 PM
Robin sharma
Robin sharma - avatar
+ 1
Thank you. It worked like a charm.
22nd Jun 2017, 12:42 PM
Sizwe Khumalo
Sizwe Khumalo - avatar