When I was writing code in Python, I came to something like this:
x = 'example'
if x == 'example' or x == 'I don\'t know' or x == 'another example':
print('Something ...')
Look at the if
statement. I could do manually all this or
-s, but what is the best way to write it if I had 100 of them? Maybe 1000? And maybe 5. (For all sizes.) Is there any way like if x == 'example or 'I don\'t know' or ...
? Note, that this isn't an opinion-based question; it asks for the best way (or short) not for your opinion.
Thank you for your help and all the time you consumed with this pretty easy question!
P.S. It could be any programming language, but I defined here python as an example.
Aucun commentaire:
Enregistrer un commentaire