Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String out of range error
#8
You're posting way more code than is necessary and no traceback. The error you show doesn't even have indexing in the code snippet.

Here's a Python session that has code that could reproduce the kind of error you're seeing
>>> "Hello, world!"[100]

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    "Hello, world!"[100]
IndexError: string index out of range
Note that there's a string, and an index operator (using square brackets).

To post less code, you should find the exactly line which is having the problem, print the string and the index before that line crashes, and post back here with as little code as possible that reproduces your problem that you need help solving. It could be as simple as what I just showed above, but if you're really reducing it, it should be fewer than 10 lines and probably fewer than 5.
Reply


Messages In This Thread
String index out of range - by Salah71 - Jan-17-2017, 06:37 PM
RE: String out of range error - by micseydel - Jan-18-2017, 06:58 PM
RE: String out of range error - by Salah71 - Jan-18-2017, 07:38 PM
RE: String out of range error - by micseydel - Jan-18-2017, 07:46 PM
RE: String out of range error - by Salah71 - Jan-18-2017, 09:11 PM
RE: String out of range error - by metulburr - Jan-18-2017, 08:42 PM
RE: String index out of range - by metulburr - Jan-17-2017, 07:08 PM
RE: String index out of range - by Salah71 - Jan-17-2017, 07:19 PM
RE: String index out of range - by snippsat - Jan-17-2017, 09:19 PM
RE: String index out of range - by Salah71 - Jan-18-2017, 04:15 AM
String out of range error - by Salah71 - Jan-18-2017, 04:21 AM
String Index out of range error - by Salah71 - Jan-18-2017, 05:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I'm getting a String index out of range error debian77 7 2,408 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  matplotlib x axis range goes over the set range Pedroski55 5 3,293 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Python Error List Index Out of Range abhi1vaishnav 3 2,381 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  python error: bad character range \|-t at position 12 faustineaiden 0 3,739 May-28-2021, 09:38 AM
Last Post: faustineaiden
  string index out of range jade_kim 4 2,687 Jan-13-2021, 05:41 AM
Last Post: jade_kim
  List index out of range error while accessing 2 lists in python K11 2 2,168 Sep-29-2020, 05:24 AM
Last Post: K11
  List index out of range error when attempting to make a basic shift code djwilson0495 4 3,058 Aug-16-2020, 08:56 PM
Last Post: deanhystad
  String index out of range - help please DudleyDiccle 7 3,484 Mar-27-2020, 12:10 AM
Last Post: DudleyDiccle
  Define a range, return all numbers of range that are NOT in csv data KiNeMs 18 7,193 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  IndexError: string index out of range ? Q_Y 5 4,791 Jul-05-2019, 07:18 PM
Last Post: noisefloor

Forum Jump:

User Panel Messages

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