Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

It says line 17 has a list index out of range can you help me?

0 votes
asked Nov 17, 2018 by anonymous
arr = [10^50]

a = 0
b = 0
c = 0
d = 0
e = 0
n = 0

x = input()
x = x.split()
a = len(x)

y = input()
y = list(y)
for i in range(0, int(len(y)) + 1):
    n = int(y[i])
    b = b + n

z = input()
z = list(z)
for i in range(0, len(z) + 1):
    if i%2 == 0:
        c = c + z[i]

w = input()
w = list(w)
for i in range(0, len(w) + 1):
    if int(w[i]) == 4:
        d = d + 1

v = input()
v = list(v)
for i in range(0, len(v) + 1):
    if len(v)%2 == 0:
        e = int(len(v))/2
        e = int(v[e])
    else:
        e = int(len(v)) - 1
        e = e/2
        e = int(v[e + 1])

print("%d\n %d\n %d\n %d\n %d\n", a, b, c, d, e)

1 Answer

0 votes
answered Nov 21, 2018 by אלון ל (140 points)
the y indexes is from 0 to len(y) - 1

you are trying to excess until len(y)+1 so you are out of range.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...