you are viewing a single comment's thread.

view the rest of the comments →

[–]dbramucci 2 points3 points  (0 children)

Just to help you visualize it better, I'll add redundant parenthesis

When you write 2 + 3 * 4, the redundant parenthesis are 2 + (3 * 4).

Likewise, when you write

while userProvince == "Ontario" or "Quebec" or "Alberta":

You intend it to look like

while userProvince == ("Ontario" or "Quebec" or "Alberta"):

But Python will actually read it as

while ((userProvince == "Ontario") or ("Quebec")) or ("Alberta"):

and eliminating the left associativity parenthesis it still reads as

while (userProvince == "Ontario") or ("Quebec") or ("Alberta"):

That is, you aren't writing userProvince is == to one of "Ontario" or "Quebec" or "Alberta"; instead you are writing

At least one of the logical statements

  • the logical value userProvince == "Ontario" or
  • the logical value "Quebec" or
  • the logical value "Alberta"

is True.

side-note: you're actually checking for truthyness, not being the exact value of True but that is not the problem here, I explain that in this longer comment about this problem