Python 15.4:Digit Sum


#1

Hello Friends, I am stuck at

https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/4?curriculum_id=4f89dab3d788890003000096#

Why doesn't my string splits
i was hoping

j= i.split(",")

will lead to ["1,2,3,4"]


def digit_sum(n):
    i=str(n)
    j= i.split(",")
    print j
    first=j[0]
    print first
    
    
print digit_sum(1234)


#2

split(",")

this will separate the string each time a , is found, which are not present:

print digit_sum(1234)

split won't work, there is no character on which you can separate

just loop over i, given you converted it to a string, you can loop over it


#3

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