Code doesnt work

def digit_sum(x):
  x = str(x)
  total = 0
  for s in x:
    integers = int(s)
    total = total + integers
  print total

this function does what its supposed to…it takes a number and sums up the digits…but i still cant pass the exercise


what error message do you get? Maybe there is clue there why the code isn’t working


it says it should return 11 but returns none…but actually it returns 11


no, your function prints 11, that is quite a difference. Function return None by default, so that is a big hint


yeah i figured it out just now…used return and now it works


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