Code is supposed to sum all numbers given by user input until only a single digit number remains.
Input 19991229 should result in 6, but I'm getting 33 instead, as if the two remaining numbers aren't summed.
Here's the code:
b_d = input("enter birthdate")
digits = []
for d in b_d:
digits.append(int(d))
print(digits)
life = 0
while (sum(digits)) >= 10 :
for x in digits:
life += x
digits.remove(x)
print(life)
this resolves the issue, but it's too ad hoc and doesn't work on all cases:
r = 0
for y in str(life):
r += int(y)
print(y)