How can I make a function
recognize if a certain variable
is inputted as an argument?
I would like to input a number of variables into the function, and if they are present, return corresponding binary variables as True
to the program.
#variables to test: x, y, z
def switch(*variables):
for var in list(variables):
#detect if var is the variable x:
switch_x = True
#detect if var is the variable y:
switch_y = True
#detect if var is the variable z:
switch_z = True
switch(x, y, z)
if switch_x is True:
#Do something
Note that I'm looking to test if the variables themselves are inputted into the function. Not the values that the variables contain.