3 Replies - 1773 Views - Last Post: 26 July 2016 - 09:41 PM Rate Topic: -----

#1 bs319  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 45
  • Joined: 21-October 14

Bad Color String Error in Python Using Turtle

Posted 26 July 2016 - 09:11 PM

I posted on stack overflow but did not get a response.

In my python program I am reading from a file and storing the contents in a list. I checked each index of the list so I know it was stored correctly. I am then passing a specific index to a class which contains the color blue. Whenever it gets to the turtle.colorI get an error bad color string: "blue"

For example:
Team = Rainbow(str(sequence[0]),str(sequence[1]), str(sequence[2])) #index 2 (str(sequence[2])) contains "blue"


The I have a class
class Rainbow:
    def __init__(self, Rname, Rteam, Rcolor):
       self.name = Rname
       self.team = Rteam
       self.color = Rcolor

       self.Rturtle = turtle.Turtle()

       self.Rturtle.color(self.color)//here is where I get the error


I made sure everything is imported correctly and did some research on the this error and only got issues with bad sequence. Also, if I pass
 Team = Rainbow("Jay","Blue Jays","blue")
I do not get the error.

I tried
self.color = Rcolor.strip()

I was wondering if someone would be able to help

Is This A Good Question/Topic? 0
  • +

Replies To: Bad Color String Error in Python Using Turtle

#2 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2343
  • View blog
  • Posts: 9,400
  • Joined: 03-December 12

Re: Bad Color String Error in Python Using Turtle

Posted 26 July 2016 - 09:34 PM

You have been a member long enough and have enough posts to know, this is not where this belongs. Moving.
Was This Post Helpful? 0
  • +
  • -

#3 bs319  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 45
  • Joined: 21-October 14

Re: Bad Color String Error in Python Using Turtle

Posted 26 July 2016 - 09:36 PM

sorry I honestly did not realize.

Turned out that there were white spaces but I had to manually fix the text file.
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2343
  • View blog
  • Posts: 9,400
  • Joined: 03-December 12

Re: Bad Color String Error in Python Using Turtle

Posted 26 July 2016 - 09:41 PM

If you pass Rcolor directly as a parameter, does the error occur?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1