When attempting the digit_sum exercise in practice makes perfect, I get the following error: Oops, try again. Does your digit_sum function take exactly one argument (a positive integer)? Your code threw a "'int' object has no attribute 'getitem'" error.
Please see my code below (which appears to work in pycharm):
I do not understand why I get the error in codeacademy and not in pycharm. Is my code incorrect?
# Function to add components of a number e.g. 1234 = 10 def digit_sum(n): list =  list_tot = 0 for i in range (len(str(n))): list.append(int(n[i])) list_tot = list_tot + list[i] return list_tot numb_txt = raw_input('Enter a positive number: ') print digit_sum(numb_txt)