lundi 22 juin 2015

If statements in python. Does not stop the other if statements from working

import turtle

print("Give me a shape") shape = input()

if shape == "pentagon" or "Pentagon": for i in range(5): turtle.fd(100) turtle.rt(72)

if shape == "triangle" or "Triangle": for i in range(3): turtle.fd(100) turtle.rt(120)

if shape == "square" or "Square": for i in range(4): turtle.fd(100) turtle.rt(90)

if shape == "hexagon" or "Hexagon": for i in range(6): turtle.fd(100) turtle.rt(60)

if shape == "circle" or "Circle": turtle.circle(100)

else: print("Not a shape")

Aucun commentaire:

Enregistrer un commentaire