Answer the question
In order to leave comments, you need to log in
IndexError: string index out of range - how to fix?
I tried to make a program that converts text from Cyrillic to Latin. Moreover, the letter combination "kv" must be converted to "qu".
"kv", of course, is converted to "qu", but if you enter just "k" instead of "kv", then instead of "k" the program gives an error "IndexError: string index out of range" on line 6: if q == "к" and qw[i+1] == "в"
:
Please help. I am attaching the code below:
qwerty = {"к": "k", "в": "v", "а": "a"}
qw = input("введи букву/слово")
i = 0
q = qw[i]
while i<len(qw):
if q == "к" and qw[i+1] == "в":
print("qu")
i += 2
else:
q = qw[i]
print(qwerty.get(q))
i += 1
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