SHARE
TWEET

Untitled

a guest Jun 17th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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']
  2. list1.sort()
  3.  
  4. #printing the last element
  5. print("Largest element is:", list1[-1])
  6. #print max(list1)
  7.      
  8. print("Largest element is:", list1[-1])
  9. ('Largest element is:', '99999')
  10.      
  11. In [40]: list1=['400160', '400161', '400162', '400163', '400164', '400165', '400166', '400167', '400168', '400169', '400170', '400171', '400172', '400173', '400174', '400175', '400
  12.     ...: 176', '400177','99990', '99991', '99992', '99993', '99994', '99995', '99996', '99997', '99998', '99999']                                                                  
  13.  
  14. In [41]: list1 = list(map(int,list1))                                                                                                                                              
  15.  
  16. In [43]: max(list1)                                                                                                                                                                
  17. Out[43]: 400177
  18.      
  19. max(list1, key=int)
  20. # '400177'
  21.      
  22. max(map(int, list1))
  23.  
  24. 400177
  25.      
  26. 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']
  27. print(max(map(int, list1)))
  28.      
  29. >>>python3 test.py
  30. 400177
  31.      
  32. max(map(int, list1))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top