boolean-logic - assign multiple values to one variable python - How to test multiple variables against a value?

python check if variable is one of two values / python / if-statement / comparison / match

I'm trying to make a function that will compare multiple variables to an integer and output a string of three letters. I was wondering if there was a way to translate this into Python. So say:

x = 0
y = 1
z = 3
mylist = []

if x or y or z == 0 :
if x or y or z == 1 :
if x or y or z == 2 :
if x or y or z == 3 : 

which would return a list of:

["c", "d", "f"]

Mad Physicist

Answer #1

If you ARE very very lazy, you can put the values inside an array. Such as

list = []
nums = [add numbers here]
letters = [add corresponding letters here]
for index in range(len(nums)):
    for obj in list:
        if obj == num[index]:

One more thing, your

if x or y or z == 0:

will compile, but not in the way you want it to. When you simply put a variable in an if statement (example)

if b

the program will check if the variable is not null. Another way to write the above statement (which makes more sense) is

if bool(b)

Another lazy way I found is :

if any([x==0, y==0, z==0])