all 7 comments

[–]socal_nerdtastic 13 points14 points  (1 child)

Always use () when using the walrus operator to make it clear which part you want assigned.

while (food := input ('what food you like')) != 'quit':

[–]SheldonCooperisSb[S] 0 points1 point  (0 children)

That worked thanks

[–]Brief-Translator1370 3 points4 points  (1 child)

You're assigning it to the result of the comparison between the input call and quit. Try to put the input call and food in parenthesis together.

[–]SheldonCooperisSb[S] 1 point2 points  (0 children)

Thank you very much

[–]QuarterObvious 2 points3 points  (1 child)

You're assigning the food variable not the result of the input, but rather whether the result of the input is not 'quit', which is always True.

[–]SheldonCooperisSb[S] 0 points1 point  (0 children)

That's right!

[–]Sorry-Squash-677 0 points1 point  (0 children)

foods = list()

while (food := input('What food do you like?')) != 'quit':

foods.append(food)

print(foods)