Skip to content
Advertisement

List has an issue

My code is:

JavaScript

I want the output to be a list from my inputs.

Why is the output [True, True, True] when there are three inputs before typing ‘quit’?

Advertisement

Answer

Looking at Operator precedence, the assignment operator := is the lowest of them all. That means that python evaluated the != first and assigned its boolean result to food2. You can use parentheses to change evaluation order:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement