I want to print the highest number from my list (1231 here).
I tried doing this here (posted below), but that doesn’t work. It just shows the highest total number for each element in my list, which is, obviously, not what I want.
list = [ [1,3,251], [2], [1231,52,22] ]
for i in range(len(list)):
for j in range(len(list[i])):
print(max(list))
prints:
[1231, 52, 22]
[1231, 52, 22]
[1231, 52, 22]
[1231, 52, 22]
[1231, 52, 22]
[1231, 52, 22]
[1231, 52, 22]
>Solution :
list = [ [1,3,251], [2], [1231,52,22] ]
new_list = []
for i in list:
new_list.append(max(i))
print(max(new_list))
This will do. This will print only the highest number from the entire list.