Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String out of range error
#6
I am trying get this code for my HS class. I don't know much about python, i know the basics. 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

IPS
scores, moves, reports = main_play([example2, team14])

Error:
[color=#000000][size=small][font=monospace]in move(my_history, their_history, my_score, their_score)      38         endtest = 0      39         endtest = ctest/btest ---> 40         if endtest >= 0.65:      41             return 'b' ---> 42         elif endtest <= 0.45: IndexError: string index out of range [/font][/size][/color]
Prisoners Dilemma.py
and here is the code for the team14.py (me)

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,399 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  matplotlib x axis range goes over the set range Pedroski55 5 3,286 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Python Error List Index Out of Range abhi1vaishnav 3 2,365 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  python error: bad character range \|-t at position 12 faustineaiden 0 3,731 May-28-2021, 09:38 AM
Last Post: faustineaiden
  string index out of range jade_kim 4 2,678 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,149 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,046 Aug-16-2020, 08:56 PM
Last Post: deanhystad
  String index out of range - help please DudleyDiccle 7 3,468 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,172 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  IndexError: string index out of range ? Q_Y 5 4,766 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