Guest User

Untitled

a guest
Dec 16th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. while n>0:
  2. d=n%10
  3. n=n//10
  4. sum+=d
  5.  
  6. def sumdigits(n):
  7. sumd = 0
  8. while n > 0:
  9. n,d = divmod(n, 10)
  10. sumd += d
  11. return sumd
  12.  
  13. items = [123, 567, 899, 999]
  14.  
  15. res = max(items, key=sumdigits)
  16.  
  17. print(res)
  18. #999
Add Comment
Please, Sign In to add comment