0

I am writing a code in python for school and I am not very advanced with python, my whole code is a turtle-drawn board game. I want to-when a turtle reaches the last space- make a turtle (A) write , bname,"Has Won!" where bname is a user input str variable. However, this line of code:

A.write(bname,"HAS WON!!!", move=False, align="left", font=("Arial", 40, "normal"))

keeps getting an error:

A.write(bname,"HAS WON!!!", move=False, align="left", font=("Arial", 40, "normal"))
TypeError: write() got multiple values for argument 'move'

Anyone know how to solve this, I don't know what to do! This is turtle by the way ;-)

AJ123
  • 194
  • 2
  • 14

2 Answers2

1

I'm guessing write is a function whose first argument is a string, second argument is a boolean indicating whether the text should move, etc etc. In which case, it accepts bname as the first argument and "HAS WON!!!" as the second argument. Then it sees that you also provided move=False and gets confused because you already said "HAS WON!!" was the value for the second argument move.

Here is a simpler example of the same error occurring:

>>> def f(a,b):
...     return a + b
...
>>> f(4, 8, b=15)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() got multiple values for argument 'b'

If you want bname and "HAS WON!!!" to be the first argument, then try concatenating them:

A.write(bname + "HAS WON!!!", move=False, align="left", font=("Arial", 40, "normal"))
Kevin
  • 74,910
  • 12
  • 133
  • 166
0

I guess move is the first or second positional argument. once you are setting that by passing bname or "HAS WON!!" and the other time you are setting that by passing keyword argument move=False.

Good examples of about positional and keyword arguments can be found here. Positional argument v.s. keyword argument

Erfan Gholamian
  • 225
  • 1
  • 9