S
S
Sergey Nizhny Novgorod2016-01-20 05:30:58
Python
Sergey Nizhny Novgorod, 2016-01-20 05:30:58

How does the or variator work in Python?

Good afternoon.
A small question.
Why this doesn't work:
elif int(step_id) == 3 or 4:
But this works:
elif int(step_id) == 3 or int(step_id) == 4:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-01-20
@Terras

The first option is not correct from the point of view of logical operations. And you will always have True.
For example step_id = 2:
For example step_id = 3:
For example step_id = 6:
And the second option is correct.
For example step_id = 2:
For example step_id = 3:
In order to understand how execution happens, you need to read about execution precedence .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question