I have written a little program that let’s the user enter his/her name and then draws a spiral with the name in four colors. The code works fine, but the names are not in color. I have reviewed it many times and I cannot find an error. I wonder, if the turtle module has the full functionality in Pythonista and if there are some restrictions.
Is there anybody that has some experience with the turtle module in Pythonista? Does the code seem incorrect to you? What would you change, that the names are printed in color?
Here is my code:
# SpiralMyName.py - prints a colorful spiral of the user's name
import turtle
t = turtle.Pen()
turtle.bgcolor('white')
colors = ['red', 'yellow', 'blue', 'green']
# Ask the user's name using turtle's textinput pop-up window
your_name = turtle.textinput('Enter your name', 'What is your name?')
# Draw a spiral of the name on the screen, written 100 times
for x in range(100):
t.penup() # Don't draw the regular spiral lines
t.forward(x*4) # Just move the turtle on the screen
t.pencolor(colors[x%4]) # Rotate through the four colors.
t.pendown() # Write the user's name bigger each time.
t.write(your_name, font = ('Arial', int((x+4)/4), 'bold'))
t.left(92) # Turn left, just as in our other spirals.
