Quite new to the realm of coding and just trying to improve a bit every day. Trying to understand exactly what's happening with this line of code:
sum(int(x) for x in str(n))
Within this function:
### digit sum
def digital_root(n):
while n>9:
n = sum(int(x) for x in str(n))
return n
print(digital_root(n))
Basically, it looks to me like the line of code is saying to convert n into a string and then x somehow represents each individual integer within the "string" and then the sum function...well, sums them?
I feel like that's not 100% accurate though for some reason. Would appreciate any clarification!