Advertisement
maynul67

Calculate sum of all digits of a number

Jul 9th, 2021
899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.13 KB | None | 0 0
  1. x = int(input("enter number: "))
  2. list =[ ]
  3.  
  4. while (x > 0):
  5.     b = x % 10
  6.     list.append(b)
  7.     x = x // 10
  8.  
  9. result = sum(list)
  10. print(result)
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement