It should be --> print(l[i]) in the "for" Loop Indentation,
What is Happening right now However is that you have done --> print(l[n]) which means it has become print(l[5]). Since n carries the length of your String it is 5 and since the Index of the Last Element is 4 it is Returning an IndexError of list Index out of Range (As the last Element has index of 4)
7
u/[deleted] Aug 17 '25
It should be --> print(l[i]) in the "for" Loop Indentation,
What is Happening right now However is that you have done --> print(l[n]) which means it has become print(l[5]). Since n carries the length of your String it is 5 and since the Index of the Last Element is 4 it is Returning an IndexError of list Index out of Range (As the last Element has index of 4)