# Callback() takes from 2 to 4 positional arguments but 6 were given

**URL:** <https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893>\
**Category:** Dash Python\
**Created:** [March 11, 2021, 7:15am UTC](https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893 "2021-03-11T07:15:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zohaib](https://avatars.discourse-cdn.com/v4/letter/z/3be4f8/32.png) [@zohaib](https://community.plotly.com/u/zohaib)\
**Post date:** [March 11, 2021, 7:15am UTC](https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893/1 "2021-03-11T07:15:04Z")

</div>

Hello,  
I am running the above-mentioned error. I am rather new to plotly, so any help would be appreciated.  
I am trying to create a dashboard in plotly.

Here is the code

```auto

@app.callback(Output(component_id ='TS_Graph_1', component_property = 'figure'),
              [Input(component_id = 'btn_TS_confirmed', component_property = 'n_clicks')],
              [Input(component_id = 'btn_TS_active', component_property = 'n_clicks')],
              [Input(component_id = 'btn_TS_recovered', component_property = 'n_clicks')],
              [Input(component_id = 'btn_TS_death', component_property = 'n_clicks')]
              )
def displayClick(btn1, btn2, btn3, btn4):
    changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
    print(changed_id)
    if 'btn_TS_confirmed-1' in changed_id:
        fig = TS_Complete_Figures[0]
        
    elif 'btn_TS_active' in changed_id:
        fig = TS_Complete_Figures[1]
        
    elif 'btn_TS_recovered' in changed_id:
        fig = TS_Complete_Figures[2]
        
    elif 'btn_TS_death' in changed_id:
        fig = TS_Complete_Figures[3]
        
    else:
        fig = TS_Complete_Figures[0]  
    return fig

```

I am trying to update a graph div once a specific button is pressed.  
I have a list of figure objects and once a button is pressed a relevant image should be displayed in the graph div

Here is the SS of my application and div structure.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/f/ff5137755a4d09e06976e850d5499f5bd4822fda.png)

Thank you

---

<div class="post-metadata">

**Author:** ![DeejL](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@DeejL](https://community.plotly.com/u/DeejL)\
**Post date:** [March 11, 2021, 7:27am UTC](https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893/2 "2021-03-11T07:27:34Z")

</div>

Can you post your full code and not just the callback decorator? Makes is easier to spot issues that might be related to what’s happening in other parts of your code.

---

<div class="post-metadata">

**Author:** ![DeejL](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@DeejL](https://community.plotly.com/u/DeejL)\
**Post date:** [March 11, 2021, 7:31am UTC](https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893/3 "2021-03-11T07:31:00Z")

</div>

Uh, oh! Just noticed that your callback decorator is passing in every single button input as a separate list. Instead you’ll need to do this:

```auto
@app.callback(Output(component_id ='TS_Graph_1', component_property = 'figure'),
              [Input(component_id = 'btn_TS_confirmed', component_property = 'n_clicks'),
              Input(component_id = 'btn_TS_active', component_property = 'n_clicks'),
              Input(component_id = 'btn_TS_recovered', component_property = 'n_clicks'),
              Input(component_id = 'btn_TS_death', component_property = 'n_clicks')]
              )

```

---

<div class="post-metadata">

**Author:** ![zohaib](https://avatars.discourse-cdn.com/v4/letter/z/3be4f8/32.png) [@zohaib](https://community.plotly.com/u/zohaib)\
**Post date:** [March 11, 2021, 8:32am UTC](https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893/4 "2021-03-11T08:32:42Z")

</div>

Got it.  
Thanks for this. Was scratching my head since yesterday. Much appreciated.

---

<div class="post-metadata">

**Author:** ![zohaib](https://avatars.discourse-cdn.com/v4/letter/z/3be4f8/32.png) [@zohaib](https://community.plotly.com/u/zohaib)\
**Post date:** [March 11, 2021, 9:16am UTC](https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893/5 "2021-03-11T09:16:15Z")

</div>

A follow-up question from side would be, should we include both states and input in on a single list or should they both be contained in their own list.  
Example: I have two inputs and two states. One list for states and a separate list for inputs,

---

<div class="post-metadata">

**Author:** ![MichelH](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MichelH](https://community.plotly.com/u/MichelH)\
**Post date:** [March 11, 2021, 10:58am UTC](https://community.plotly.com/t/callback-takes-from-2-to-4-positional-arguments-but-6-were-given/50893/6 "2021-03-11T10:58:06Z")

</div>

> [@zohaib](#):
>
> should we include both states and input in on a single list or should they both be contained in their own list.

Inputs and States should be seperate lists, with the input list coming before the state list.

In recent versions of Dash, you don’t need the lists at all, you can simply pass all Outputs, Inputs and States to @app.callback separated by commas. Note that the order is still crucial, though: First all Outputs, then all Inputs and then all States.

Read the Basic Callbacks chapter of the tutorial for more information on this.

> **[Part 2. Basic Callbacks | Dash for Python Documentation | Plotly](https://dash.plotly.com/basic-callbacks)**
>
> Dash apps are made interactive through Dash Callbacks: chainable functions that are automatically called whenever a UI element is changed.
