Bad color string error when running my program.

Hi there, I am currently doing a programming class that involves using Python. It has been very basic stuff so far but I have run into an issue when using the input() command. So basically my assignment was to use Turtle Graphics in Python to write the words Hello by using variables, but also have the user input a pen color for the letters and a pen width. I did this as my class instructed and wrote the following:

pen_color=input("Enter a color name to set the pen color: ") pen_width=input("Enter a number from 1-10 to set the pen width: ")

Then later down down the code I called these variables using these:

color(pen_color) width(pen_width)

So after writing this, I ran the program from the Python Shell and it asked for a color and number, which I entered and everything worked perfectly. But then I tried to just run the program normally, which is where my issue comes in. I clicked it, then it asked me to enter the color and width like it should. But as soon as I hit enter, the program runs for a moment then closes. Now I know that when I program has bugs or errors, it will do this but I know there is nothing blatantly wrong with it otherwise the error would've been identified in the Shell. The other reason I know this error is strange is that text pops up on the screen right before it closes. It disappears very quick, so I had to take a slow-mode video of my screen to see what was wrong. And doing this revealed what the error was. It said this exactly: turtle.TurtleGraphicsError:bad color string: whatever color I entered. I tried looking around for this error and nothing seemed to come up. So if anyone could help that would be greatly appreciated. As a side note I am using Windows 10 and Python 3.2. Thanks again to anyone.

Posted Aug 17, 2017, 8:21 PM UTC

08
Loading comments…