Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list1=['400160', '400161', '400162', '400163', '400164', '400165', '400166', '400167', '400168', '400169', '400170', '400171', '400172', '400173', '400174', '400175', '400176', '400177','99990', '99991', '99992', '99993', '99994', '99995', '99996', '99997', '99998', '99999']
- list1.sort()
- #printing the last element
- print("Largest element is:", list1[-1])
- #print max(list1)
- print("Largest element is:", list1[-1])
- ('Largest element is:', '99999')
- In [40]: list1=['400160', '400161', '400162', '400163', '400164', '400165', '400166', '400167', '400168', '400169', '400170', '400171', '400172', '400173', '400174', '400175', '400
- ...: 176', '400177','99990', '99991', '99992', '99993', '99994', '99995', '99996', '99997', '99998', '99999']
- In [41]: list1 = list(map(int,list1))
- In [43]: max(list1)
- Out[43]: 400177
- max(list1, key=int)
- # '400177'
- max(map(int, list1))
- 400177
- list1=['400160', '400161', '400162', '400163', '400164', '400165', '400166', '400167', '400168', '400169', '400170', '400171', '400172', '400173', '400174', '400175', '400176', '400177','99990', '99991', '99992', '99993', '99994', '99995', '99996', '99997', '99998', '99999']
- print(max(map(int, list1)))
- >>>python3 test.py
- 400177
- max(map(int, list1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement