How I define OR in code?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Eidam

How I define OR in code?

I need write something like this:

if var == 1 or 2 or 3:
   do something()

Thank you for answer.

:bust_in_silhouette: Reply From: kidscancode

You need to make all of the comparisons:

if var == 1 or var == 2 or var == 3:

For the same conditions, you could also do:

if var >= 1 and var <= 3:

And one more option:

if var in [1, 2, 3]:

All three statements are equivalent.

That’s exactly what I needed!
Thank you very much

Eidam | 2020-05-04 17:00

Is there any way to say and/or? Like, say you have a settings button in your pause menu that you could cycle over to with keyboard clicks and/or the mouse cursor…

if get_focus_owner() == settingsButton and or settingsButton.is_hovered():

Would anything work here?

PIZZA_ALERT | 2022-04-18 03:13