Python Forum
IndexError: string index out of range ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndexError: string index out of range ?
#2
That error happens when a string index used is not a valid index of the string.

In the next example the last index of 'string' is 5, using 6 gives the error.

>>> 'string'[6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
Reply


Messages In This Thread
IndexError: string index out of range ? - by Q_Y - Jul-04-2019, 06:10 PM
RE: IndexError: string index out of range ? - by Yoriz - Jul-04-2019, 06:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  IndexError: index 31 is out of bounds for axis 0 with size 31 YL789 1 879 Sep-21-2024, 09:46 AM
Last Post: Gribouillis
  IndexError: index 10 is out of bounds for axis 0 with size 10 Mehboob 11 9,918 Sep-14-2023, 06:54 AM
Last Post: Mehboob
Thumbs Down I hate "List index out of range" Melen 20 9,033 May-14-2023, 06:43 AM
Last Post: deanhystad
Exclamation IndexError: Replacement index 2 out of range for positional args tuple - help? MrKnd94 2 13,820 Oct-14-2022, 09:57 PM
Last Post: MrKnd94
  IndexError: list index out of range dolac 4 3,380 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  I'm getting a String index out of range error debian77 7 3,892 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  IndexError: list index out of range Anldra12 2 2,227 May-03-2022, 01:39 PM
Last Post: Anldra12
  matplotlib x axis range goes over the set range Pedroski55 5 6,551 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  IndexError: list index out of range rf_kartal 6 4,560 Sep-07-2021, 02:36 PM
Last Post: Larz60+
  Python Error List Index Out of Range abhi1vaishnav 3 4,214 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020