close

[Solved] Type: got multiple values for argument

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Type: got multiple values for argument in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Type: got multiple values for argument Error Occurs?

Today I get the following error Type: got multiple values for argument in python.

How To Solve Type: got multiple values for argument Error ?

  1. How To Solve Type: got multiple values for argument Error ?

    To Solve Type: got multiple values for argument Error I had the same problem that is really easy to make, but took me a while to see through.

  2. Type: got multiple values for argument

    To Solve Type: got multiple values for argument Error I had the same problem that is really easy to make, but took me a while to see through.

Solution 1

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 color"blellow" as positional and "green" as keyword. (painter.draw_box is supposed to accept the height and width arguments).

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")

Here, color is assigned 20, then args=[30] and color is again assigned "green".

Solution 2

I had the same problem that is really easy to make, but took me a while to see through.

I had copied the declaration to where I was using it and had left the ‘self’ argument there, but it took me ages to realise that.

I had

self.myFunction(self, a, b, c='123')

but it should have been

self.myFunction(a, b, c='123')

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read