Digit_sum long version not working



So, I found a much, much shorter way to finish this excercise. But still, I want to know why this one isn't working:

Your function fails on digit_sum(434). It returns 77 when it should return 11.

The screen show that the addition is being done properly, but it does show a 'none' right below the result.

str_n = []
separated_string = []

def string_converter(y):

def str_separator(m):
    for item in m:
        for i in item:

digit_list = []

def inte_converter(e):
    for item in e:

def digit_sum(n):
    total = 0
    for item in digit_list:
        total += item
    return total

print digit_sum(434)


Hey we need a mod or two!

That's so weird, I don't know if I can help though...


This could just be a bug in Codecademy. Because It's printing and returning the right amount but you're not passing.


I'm gonna talk to a mod



Yeah I was thinkin just that. Although it would make perfect sense; If I had passed that excercise with this code,
I wouldnt´ve found the simple and more efficient way to do it. I think that might be a reason why this one wasn´t getting through.

Your reply is very much appreciated.


You`re welcome but no mod has come :smiley:


I guess this code is wrong. we use this code in list of list.

def str_separator(m):
    for item in m:
        for i in item:

just do
for item in m:
and simpler ways to do is first convert , then seprate ,then convert and last add.
My code finish only in 13 lines.


Well, I've completed python already and back when I posted this I had already worked a much shorter way to do it, I
was just curious as to why it wasn't working if it displayed the right output.

I guess it was just to long for the course requirements or something. Anyway...


Can anyone here figure out to print all ?


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