samedi 16 février 2019

Is there any way to make if...or... statements in Python shorter? [duplicate]

This question already has an answer here:

Sorry if the title is confusing, but actually my question is very simple.

Is there any way I can shorten this so that I don't have to write "var" thrice?

if var == 3 or var == 7 or var == 10:
    print("Nice numbers")

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire