How to find the maximum variable in a list in python
MikeJMS8910

So here is my code -

var1 = 1
var2 = 2
var3 = 3
varList = [var1, var2, var3]

I want to find which variable has the highest value but then get the variable. This means that I can't use max because the value would be 3 instead of var3, but I want var3.

You are viewing a single comment. View All
IOP3

You need to do print(max(var_List))

MikeJMS8910

@IcingHackz thats not what I mean
if I were to do that it will just give me 3 since that is the top value but I also want to find which variable holds the highest value

IOP3

@MikeJMS8910 I don't think that's possible to get the variable with the highest value, you only can get the value that's the highest. :P

MikeJMS8910
MikeJMS8910

@IcingHackz do you know anyone who could know?....

IOP3

@MikeJMS8910 probably the people who have the most cycles like @Coder100, @RYANTADIPARTHI, or @Bookie0

Coder100
IOP3

@Coder100 he asked a question, I answered it

RYANTADIPARTHI

@MikeJMS8910

try this code. It works.

Bookie0