def sum_tail(n, s = 0): if n == 0: return s else: return sum(n // 10, n % 10 + s) def sum( n ): if n == 0: return 0 else: return n % 10 + sum(n // 10) def main(): n = int(input("n=")) print(sum_tail(n)) main()
12345
n=
Traceback (most recent call last): File "./prog.py", line 28, in <module> File "./prog.py", line 26, in main File "./prog.py", line 9, in sum_tail TypeError: sum() takes 1 positional argument but 2 were given
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!