Hello, I wrote the code in Python, but I got a compilation error, so I'm asking you a question.
Please explain which part is wrong
Problem: Split the input integers and write a code that adds the sum of each digit in the integer. Example: input: 1234, output: 10
// Enter code here
n = int("Enter an integer":"))
a = str(n)
b = len(a)
c = 0
for i in range(0,b+1):
d = a[i]
e = int(d)
c = c+e
print(c)
Good job.
One problem is that in an array or list with length b, the index is up to b-1.
606 Uncaught (inpromise) Error on Electron: An object could not be cloned
567 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
599 GDB gets version error when attempting to debug with the Presense SDK (IDE)
577 PHP ssh2_scp_send fails to send files as intended
567 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.