# Digit_sum long version not working

#1

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):
str_n.append(str(y))

def str_separator(m):
for item in m:
for i in item:
separated_string.append(i)

digit_list = []

def inte_converter(e):
for item in e:
digit_list.append(int(item))

def digit_sum(n):
string_converter(n)
str_separator(str_n)
inte_converter(separated_string)
total = 0
for item in digit_list:
total += item

print digit_sum(434)``````

Hey we need a mod or two!
#2

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

#3

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

#4

I'm gonna talk to a mod

#5

Thanks!

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.

#6

You`re welcome but no mod has come

#7

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:
separated_string.append(i)``````

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

#8

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...

#9

Can anyone here figure out to `print all` ?

#10

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