Write a program that receives an integer in the input, computes and prints the sum of the digits of this number in the output
Example:
>>>Digite um número inteiro: 123 >>>6
Tip: To separate the digits, remember: the "//" operator makes an entire division throwing away the rest, ie, that which is smaller than the divisor; The operator "%" returns only the rest of the whole division throwing out the result, ie everything that is greater than or equal to the divisor.
I did the code though, it has a repetition bug that I can not solve. Can anyone help me?
x=int(input("Digite um número para que seus digitos sejam somados: "))
soma=0
while (x>0):
resto = (x // 10)%10
resto_cont=(x%10)
resto_cont2=(x//100)
soma = resto + resto_cont + resto_cont2
print("valor é", soma)