Hey what is going on here?


#1

In Practice makes Perfect 4 .digit_sum I get this error message:
Oops, try again. Your function fails on digit_sum(434). It returns None when it should return 11.
And the funny thing is that I get the result 11 when I put 434 in the function.
Here is my code, I don't have any syntax errors in it .

def digit_sum(n):
 x=str(n)
 k=[]
 z=0
 for i in range(len(x)):
  k.append(x[i])
 for j in k:
     z+=int(j)
 print z

digit_sum(434)

#2

You have to return calculated value, not print it out :slight_smile:


#3

Today I went from 30% to 67%, I think I need a break for today.
Thanks for the answer though.


#4

Even in case of basic courses, like this one, it is usually a good idea to implement study blocks, 50 minutes of learning with a 10-minute break is a good scheme.

You're welcome.


#5

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