Cosmic
Cosmic

Reputation: 1

python turtle won't change color

I am a beginner to python and I am meant to be creating a piece of code that draws any angle, but the angle should turn red if the angle is 90 degrees. In my situation though, it won't change color.

from turtle import *
Angle = int(input('How many degrees? '))
if Angle == '90':
  pencolor('red')

pensize(5)
forward(100)
backward(100)
left(Angle)
forward(100)

I don't know what is wront with this code.

Upvotes: 0

Views: 162

Answers (1)

Erich
Erich

Reputation: 1848

Angle is an int, but you compare to a string. You have to compare to an int instead:

if Angle == 90:
    pencolor('red')

Upvotes: 0

Related Questions