maynul67

Calculate sum of all digits of a number

Jul 9th, 2021
862
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data