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...
- Thread Starter
Where are the variables D and E coming from?
And can you give an example of what the input file looks like?
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.