I have tried to use the max code but it printed out the largest number not the variable name.
textfile = open("Preference.txt","r")
for x in textfile:
preferline = x.strip('\n').split(",")
Is there a code to print out the variable with the highest values...
x Turn on thread page Beta
- Thread Starter
- 25-10-2017 12:03
- 26-10-2017 13:16
Where are the variables D and E coming from?
And can you give an example of what the input file looks like?
- 26-10-2017 13:56
you could try
biggest = max(A,B,C,D,E)
if A == biggest:
if B == biggest:
etc for each variable. This will find the biggest value and print the names of all the variables with that value. If you only want it to print the name of one of the variables with the maximum value, use elif instead of if.