What code should I use to customize the shape and color freely in Python Turtle graphics?

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

import turtle as t
t.shape('turtle')
color=float(input('turtle color==>')
t.pencolor("color")

I don't understand why there is an error. Numbers work, but strings don't work.

python

2022-09-20 10:56

1 Answers

>>> float("33")
33.0
>>> float("abcde")
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    float("abcde")
ValueError: could not convert string to float: 'abcde'

>>> float(input(""))
11.11
11.11

>>> float(input(""))
1
1.0
>>> float(input(""))
red
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    float(input(""))
ValueError: could not convert string to float: 'red'
>>> 


2022-09-20 10:56

If you have any answers or tips


© 2022 pinfo. All rights reserved.