Get name of variable with highest integer from list Python 3.3.4 -


Recently

(as in Python) tried to do something similar Value of variable, not variable name.

My array looks like this:

  x = 1 y = 2 z = 3 alloutputs = [x, y, z]  

Alloutputs [alloutputsindex (max alloutputs))

Although it is still giving the integer round of the highest value!

How can I get the names of X, Y, or Z back to the largest? @HhngenCoachchan says that you have to use a dictionary or named taple, you can use a dictionary like this:

  & gt; & Gt; & Gt; D = {'x': 1, 'y': 2, 'z': 3}> gt; & Gt; Maximum (D, Key = D.get) 'z'  

Comments