I am starting in python and in this code I send below whenever the execution of the syntax error invalidates. Can you give me some help?
lst=[6,10, 2, 1, 9, 35]
lstord= sorted(lst)
lstord.reverse()
print max (lstord)
Thank you
I am starting in python and in this code I send below whenever the execution of the syntax error invalidates. Can you give me some help?
lst=[6,10, 2, 1, 9, 35]
lstord= sorted(lst)
lstord.reverse()
print max (lstord)
Thank you
The error does not have to do with the max()
function, but with the way you are doing the print, in python 3.x it is required that there is parenthesis to execute print
:
lst=[6,10, 2, 1, 9, 35]
lstord= sorted(lst)
lstord.reverse()
print(max(lstord)) # 35
Regarding the program, if it is the learning you are doing, ignore this, but if it is just to get max
, excuses to do so many operations, you can stay just for:
lst=[6,10, 2, 1, 9, 35, 10]
print(max(lst)) # 35