menu

Questions & Answers

How to make User input choose shape of turtle
import turtle


player = input('Pick Circle or Arrow')
if player == Arrow:
    turtle.Turtle()
    turtle.shape(Arrow)
elif player == Circle:
    turtle.Turtle()
    turtle.shape(Circle)
else:
    print ('Choose Circle or Arrow')

sorry if this is a stupid question, I am new to coding. This is for a maze game where the user can pick the shape of the turtle, I've tried a lot of stuff but it doesn't work, if you can help it would be great thanks.

Answers(1) :

The return value of input() is a string, so you need to compare against it with a string.

import turtle


player = input('Pick Turtle or Arrow')
if player == "Arrow":
    turtle.Turtle()
    turtle.shape("Arrow")
elif player == "Circle":
    turtle.Turtle()
    turtle.shape("Circle")
else:
    print ('Choose Turtle or Arrow')

if you don't have the quotation marks around Arrow and Circle, python thinks that they are variable names.

Comments:
2023-01-24 00:30:12
Thank you so much for your help, it works now