Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String out of range error
#11
Quote:I really don't understand what i need to do. Like i said i  only know basics
To help you we need some things...
1) We need a simplified code. This is your problem as an example to us in terms of no more than 20 lines. In 20 lines you can give a snippet of anything done. This should not require importing numerous modules. You will find that splitting out your problem from a large code is what programmers do. 
2) Even if we wanted to run your code. We cant. You have numerous other team modules that makes it unrunnable for us. Normally you should do #1. But even if you gave the full code, you should at least make it runnable for us. In terms of how many modules your programs use, you cannot post them all here in posts...just too many modules. This is what repos are for. In this way people can just download your repo and run it without putting it together themselves. And then they can just post back on the forums the fix.
3) Your code is not indented properly. This may/may not be your fault due to a forum bug. Try to convert all tabs to spaces and post back. But you should be using spaces over tabs anyways nullifying the forum bug. And if you did either #1 or #2, it would not matter anyways. 20 lines of code can normally be indented by knowledgeable programmers. 
4) The error output you gave is not normal by python. A normal error traceback by python is in the form of...
Error:
>>> 1/0 Traceback (most recent call last):   File "<stdin>", line 1, in <module> ZeroDivisionError: integer division or modulo by zero
and micseydel example traceback as well. I can tell you right now, your traceback would not look like that if you open up a command prompt/terminal and executed your root file. This is the traceback we need. 
5) forums do not take in a piece of code or a program with a bug, and output the fix to it. We help you along the way. We dont do it for you. If this is an assignment, then your instructor gave you the tools beforehand to accomplish it. The person/people that know the code the best are the people that wrote it. We know nothing and the below quote doesnt really mean anything to us. And to be honest, i dont want to get so involved into that i do. Back to #1. 
Quote:We are trying to create strategy in Prisoners Dilemma. I got most of mine working, i just need this part to work, and it looks like its not. I get the error when i try to tell Prisoners Dilemma to use the strategy on team14.py against example2
6) Remove all your comments before posting. There are way too many comments. Comments are useful when used properly. In this case there is so much it is just noise.  We do not need you to tell us what code does. For one we know what it does, and for two we cant trust it.
7)
Quote:their_history and my_history stores string like 'bcbcccbccb' B for betray collude
Again we dont want you to tell us what it is. What we want is a snippet. An example of a snippet of code and its execution (traceback error) is as follows...

s = 'bcbcccbccb'

def move(s):
    return s[-44]
    
move(s)
Output:
metulburr@ubuntu:~$ python test.py Traceback (most recent call last):   File "test.py", line 7, in <module>     move(s)   File "test.py", line 5, in move     return s[-44] IndexError: string index out of range
Recommended Tutorials:
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,361 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  matplotlib x axis range goes over the set range Pedroski55 5 3,231 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Python Error List Index Out of Range abhi1vaishnav 3 2,325 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  python error: bad character range \|-t at position 12 faustineaiden 0 3,703 May-28-2021, 09:38 AM
Last Post: faustineaiden
  string index out of range jade_kim 4 2,641 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,138 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,009 Aug-16-2020, 08:56 PM
Last Post: deanhystad
  String index out of range - help please DudleyDiccle 7 3,421 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,098 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  IndexError: string index out of range ? Q_Y 5 4,709 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