(Nov-23-2019, 10:05 PM)ThomasL Wrote: Maybe because the items in list_highest are strings and not integers.
Yes, Thank you.
Is there any other methods to access those lists and print it using max() inside the loop?
Any help would be appreciated.
Let me share more info.
###########################################################
The values from “testname.txt” has been appended to the following lists.
“testname.txt” adde below.
name sub1 sub2 sub3 sub4
mark 20 50 40 20
teo 40 60 60 50
jain 60 70 70 60
lue 80 40 80 30
hed 40 30 30 40
The code is formatted and pasted below.
f = open ( "testname.txt" , "r" )
list1 = [ 20 , 40 , 60 , 80 , 40 ]
list2 = [ 50 , 60 , 70 , 40 , 30 ]
list3 = [ 40 , 60 , 70 , 80 , 30 ]
list4 = [ 20 , 50 , 60 , 70 , 40 ]
r = 0
for j in f:
if r = = 0 :
r = 1
k = j.split() #'i' was typo
list_names = [] #will hold the list names
list_names.append(k[ 1 ])
list_names.append(k[ 2 ])
list_names.append(k[ 3 ])
list_names.append(k[ 4 ])
else :
w = j.split()
list_highest = []
list_highest.append(w[ 1 ])
list_highest.append(w[ 2 ])
list_highest.append(w[ 3 ])
list_highest.append(w[ 4 ])
print ( "The highest values of" ,list_names[j], "=" , max (list_highest)) #, max(list_highest)) ==> is not working
Q: with respective to this code above, Is there any ways to print the max() elements in the loop.
##############################################################################