TypeError: got multiple values for argument
I read the other threads that had to do with this error and it seems that my problem has an interesting distinct difference than all the posts I read so far, namely, all the other posts so far have the error in regards to either a user created class or a builtin system resource. I am experiencing this problem when calling a function, I can't figure out what it could be for. Any ideas?
BOX_LENGTH = 100 turtle.speed(0) fill = 0 for i in range(8): fill += 1 if fill % 2 == 0: Horizontol_drawbox(BOX_LENGTH, fillBox = False) else: Horizontol_drawbox(BOX_LENGTH, fillBox = True) for i in range(8): fill += 1 if fill % 2 == 0: Vertical_drawbox(BOX_LENGTH,fillBox = False) else: Vertical_drawbox(BOX_LENGTH,fillBox = True)
Horizontol_drawbox(BOX_LENGTH, fillBox = True) TypeError: Horizontol_drawbox() got multiple values for argument 'fillBox'
This happens when a keyword argument is specified that overwrites a positional argument. For example, let's imagine a function that draws a colored box. The function selects the color to be used and delegates the drawing of the box to another function, relaying all extra arguments.
def color_box(color, *args, **kwargs): painter.select_color(color) painter.draw_box(*args, **kwargs)
Then the call
color_box("blellow", color="green", height=20, width=30)
will fail because two values are assigned to
"blellow" as positional and
"green" as keyword. (
painter.draw_box is supposed to accept the
This is easy to see in the example, but of course if one mixes up the arguments at call, it may not be easy to debug:
# misplaced height and width color_box(20, 30, color="green")
color is assigned
color is again assigned
★ Back to homepage or read more recommendations: