I've got a lot of variables that their values are user's inputs. So I want if input == 0 value of variable becomes it's name! I know I can try:
Var = something if something else "var"
But in real code, "something" part is very long and code will be WET. I tried to define a function, but there is another problem:
X = 9
Y = 0
Def f(x):
digit_finder = max(list(map(lambda x:abs(x) , re.findall(r'\d+', str(x))
if digit_finder > 0:
x = x
else:
x = str(x)
return x
Print(f(x))
Print(f(y))
Pri
>>> 9
>>> 0.0 # I want this part returns "y"