Write a program that asks the user to input a positive integer.
Your program should find and display the sum of digits of number.
For example, sum of digits of number 32518 is 3+2+5+1+8 = 19.

Source Code

num = int(input("Enter a positive integer: "))
temp = num
sum = 0

while temp > 0:
    digit = temp % 10
    sum += digit
    temp = temp // 10

print("Sum of digits of", num, "is", sum)

Output

Enter a positive integer: 4562
Sum of digits of 4562 is 17