from swampy.TurtleWorld import *
import random
world = TurtleWorld()
Turtle_1 = Turtle()
print('*****Welcome to Sehir Minesweeper*****')
print('-----First Turtle-----')
Turtle_1 = input('Please type the name of the first Turtle:')
print('Turtle 1 is' +' ' + Turtle_1)
T1_color = input('Please choose turtle color for' + ' ' + Turtle_1 +' '+'(red, blue or green):')
Turtle_1.color(T1_color)
Asked
Active
Viewed 425 times
-2

ismail
- 46,010
- 9
- 86
- 95

yusuf ziya ozgul
- 13
- 1
-
1At first glance it might seem like all the stuff nagging you about [how to ask a good question](https://stackoverflow.com/help/how-to-ask) is really annoying, but actually it's trying to help you get answers. If you tell us what you're expecting, what's going wrong, whether you have any error messages, what research you've done etc you're much more likely to get an answer than you are by posting a block of code with no context. Really, it's in your best interests, so people feel like helping you! :-) – Ari Cooper-Davis Nov 10 '19 at 16:42
2 Answers
1
This is an attempt to call a string. The error that results is TypeError: 'str' object is not callable
.
Turtle_1.color(T1_color)
color
is a string property of Turtle
. To set the color, use:
Turtle_1.set_color(T1_color)
Which is the same as:
Turtle_1.color = T1_color
Turtle_1.redraw()

Dan D.
- 73,243
- 15
- 104
- 123
1
You created Turtle_1
as a Turtle
object, which is correct. Then, however, with the line Turtle_1 = input('Please...')
, you set Turtle_1
to a string, as input()
returns a string. When you then attempted to call the color()
method, this did not work, as strings have no such method. In addition, Turtles also have the set_color()
method for setting the color, and color
is an attribute and cannot be called.

Nobozarb
- 344
- 1
- 12
-
how can i fix that i want the player to name the turtle but i need it to be a turtle aswell :D – yusuf ziya ozgul Nov 10 '19 at 18:46
-
I would use another variable called something like T1_name and then just use `T1_name = input('Please type the name of the first Turtle: ')`. Then you would also want to replace `Turtle_1.color(T1_color)` with `Turtle_1.set_color(T1_color)`. – Nobozarb Nov 10 '19 at 18:51