Your code is unreadable: when you paste code, you need to use the "Paste as" option "Code Block", or use the
code
widget on the toolbar above the text box. That tells the system that < and > characters are part of your code and shouldn't be interpreted as HTML:
While(i<L)will be truncated at the < character as it encloses HTML tags in browsers - as can be seen in yoru code.
Enclosed, it looks like this:
n=int(input())
L=len(n)
i=0
while(i<L)
print("ABCD"[i])
...
Which is a lot more readable!
To fix your problem, we have to guess what you wrote, but it's probably a simple beginner mistake:
If you have a string of 4 characters, then it's
len
is 4
But the valid indexes start from zero:
0, 1, 2, 3
So if your loop runs from to to len inclusive you are trying to access a character that doesn't exist, and you get an error.
Reduce the limit by one to
L - 1
and the error will go away.
But ... why are you converting the input to a integer, then trying to get the length of it anyway?