Answer the question
In order to leave comments, you need to log in
Error string index out of range?
a friend threw off a code that makes letters from numbers. Example 01=a 02=b. If I write 0201 then the program should display ab. It throws an error string index out of range. Who knows how to solve it please tell me.
a = input()
dict = { "01" : "a",
"02" : "b"
}
n = 0
m = 1
for i in range(0, len(a)-1):
k = a[n ]
f = a[m]
p = k + f
print(dict[p])
n = n + 2
m = m + 2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question