0
am starting me in python and in this code I send below whenever the syntax error execution invalidates. Can you give me a help?
lst=[6,10, 2, 1, 9, 35]
lstord= sorted(lst)
lstord.reverse()
print max (lstord)
Thank you
0
am starting me in python and in this code I send below whenever the syntax error execution invalidates. Can you give me a help?
lst=[6,10, 2, 1, 9, 35]
lstord= sorted(lst)
lstord.reverse()
print max (lstord)
Thank you
1
The error has nothing to do with the function max()
but with the way you are doing the print, in python 3.x it is required that there is parentesis to execute the print
:
lst=[6,10, 2, 1, 9, 35]
lstord= sorted(lst)
lstord.reverse()
print(max(lstord)) # 35
As far as the program is concerned, if it’s learning that you’re doing it, ignore this, but if it’s just to get the max
, you don’t have to do so many operations, you can just:
lst=[6,10, 2, 1, 9, 35, 10]
print(max(lst)) # 35
0
Lack in print ()
That way you get the result you want:
lst = [6, 10, 2, 1, 9, 35]
lstord = sorted(lst)
lstord.reverse()
print(max(lstord))
Browser other questions tagged python python-3.x
You are not signed in. Login or sign up in order to post.
Thank you. Very easy solution but not via.
– Nuno Oliveira
You’re welcome @Nunooliveira.
– Miguel