Digit_Sum


#1

Here’s a link to the exercise I am stuck at:
https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/4?curriculum_id=4f89dab3d788890003000096#

I can’t figure out how to split the number(in string format) into different digits so that I can add them up. Can anyone tell me how to do it or give me a hint?


#2

once you have the numbers in string format, you can simply use a loop to get each digit?


#3

just simply, convert the input into to string str(x) then iterate it while converting it into digit int(x) then
add them all. y += int(x). return y.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.