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
#12
(Jan-18-2017, 07:46 PM)micseydel Wrote:
(Jan-18-2017, 07:38 PM)Salah71 Wrote: I really don't understand what i need to do.
Do you have any specific questions about what I said?

I don't know what you mean by IPS; is it an automated grading system?

I'm doubtful that Python is generating that error report. If the error report is from your instructor, or software they're using, you should probably check with them. It's probably a bug on their side and they should be able to help you with a workaround for that.

We can't run your code without making a bunch of changes since it relies on the other teams. It hasn't been narrowed down to any specific part of the code. The problem needs to be specified more. I'm not saying you can't be helped, but you're more likely to get help if you simplify the question so that people can help faster. For example, I'm at work right now, and answer questions in between running tests and such. This is too big for me to dig into, as-is.
IPS = IPythonSession. I use canopy to code
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I'm getting a String index out of range error debian77 7 2,280 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  matplotlib x axis range goes over the set range Pedroski55 5 3,110 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Python Error List Index Out of Range abhi1vaishnav 3 2,239 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  python error: bad character range \|-t at position 12 faustineaiden 0 3,643 May-28-2021, 09:38 AM
Last Post: faustineaiden
  string index out of range jade_kim 4 2,565 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,060 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 2,934 Aug-16-2020, 08:56 PM
Last Post: deanhystad
  String index out of range - help please DudleyDiccle 7 3,310 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 6,877 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  IndexError: string index out of range ? Q_Y 5 4,603 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