TypeError: the argument of type object after * must be iterative, not int in Python
Dung Do Tien Sep 23 2021 118
I am creating a animal program that will draw a Christmas tree and some knickknacks. I want the baubles to have random colors and go to random points on the Christmas tree. This is my code:
turtle.goto(random.randint(1,16)),(random.randint(1,18))
However, when I run the program, this error appears:
TypeError: the argument of type object after * must be iterative, not int
How do I fix this? I'm using Python 3.8.2.
Thanks for any suggestions.
Have 2 answer(s) found.
- S0
Simeon Ezechinyere Sep 23 2021
I don't know about animal, but my best guess is that there is a problem with your brace:
animal.goto(random.randint(1,8)),(random.randint(1,8))
Change it to:
animal.goto(random.randint(1,8), random.randint(1,8))
I hope it works for you.
- M0
Manish Kumar Sep 23 2021
You can declare two variable and pass them into
goto(x, y)
method as below:x = random.randint(1,16) y = random.randint(1,16)
And call them:
animal.goto(x, y)
Hope it helpful for you.
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.