Python 15.4:Digit Sum


Hello Friends, I am stuck at

Why doesn't my string splits
i was hoping

j= i.split(",")

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

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



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


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