DEV Community

Discussion on: Daily Challenge #264 - Digital Root

Collapse
 
filopd profile image
Priyesh Naik • Edited

Python 3 (indent 3 is not reflecting in comment)

ip_val = input("Enter the number?")

if ip_val.isdigit():
while len(ip_val) > 1:
res = 0
for e in ip_val:
res += int(e)
ip_val = str(res)
print(ip_val)