Can you help me understand why my digit_sum function is bad?


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/4?curriculum_id=4f89dab3d788890003000096#


I'm getting the following error message: Oops, try again. Does your digit_sum function take exactly one argument (a positive integer)? Your code threw a "'int' object is not iterable" error.


def digit_sum(n):
    total = 0
    str(n)
    for c in n:
        int(c)
        total = total + c
    return total


#2

Did you mean to assign this to a variable?

Did you intend to write this in the next line, instead?

... + int(c)

#3

Hmmm...I'm not quite sure that I understand what you're hinting at. I adjusted my code based on what I thought you were implying, but I must be wrong because it's throwing the same error.

def digit_sum(n):
    total = 0
    str(n) == n
    for c in n:
        total = total + int(c)
    return total

#4

Wait, I got it! I just needed to take a fresh look at my own code. Thank you so much for your help!


#5