I am currently learning walrus := , and when I do this coding and add to the list and then print it, a list appears with all the items True.
foods = []
while food := input("what food do you like: ") != 'quit':
foods.append(food)
enter code here
print(foods)
The walrus operator assignment has lower precedence as compared to the relational operators. So saying:
Evaluates as
And until the input is
quit
it always returnsTrue
causing all values offood
to beTrue
and foods to be a list of allTrue
.You can try using: