# How to fix: "Error: missing 2 required positional arguments"? (basic python)

**URL:** <https://discuss.python.org/t/how-to-fix-error-missing-2-required-positional-arguments-basic-python/49666>\
**Category:** Python Help\
**Created:** [March 27, 2024, 3:55pm UTC](https://discuss.python.org/t/how-to-fix-error-missing-2-required-positional-arguments-basic-python/49666 "2024-03-27T15:55:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![speedpoet](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@speedpoet](https://discuss.python.org/u/speedpoet)\
**Post date:** [March 27, 2024, 3:55pm UTC](https://discuss.python.org/t/how-to-fix-error-missing-2-required-positional-arguments-basic-python/49666/1 "2024-03-27T15:55:31Z")

</div>

This is the code I’m working with. This is my function below, but I’m getting the error in the first line (def calculateBMI…). Now, I did some research and it says height and weight are passing thru to the function, but idk how to resolve it. Above this, I have height and weight already defined as variables with inputs. So I’m not understanding why it would give me this error:

> TypeError: calculateBMI() missing 2 required positional arguments: ‘height’ and ‘weight’

Any help appreciated, thank you.

`height=float(input("What is your height in inches?\n"))`

`weight=float(input("What is your weight in pounds?\n"))`

```python
def calculateBMI(height: float, weight: float):
    if (not isinstance(height, float)) | (not isinstance(weight, float)):
        raise TypeError("height and weight variables not of type float")
    print(height)
    print(weight)

```

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [March 27, 2024, 4:32pm UTC](https://discuss.python.org/t/how-to-fix-error-missing-2-required-positional-arguments-basic-python/49666/2 "2024-03-27T16:32:23Z")

</div>

When you call the function you must provide 2 parameters and you did not.  
You have not shared the code that does the call so I do not know what you tried.

The call should look something like:

```python
h = float(input("What is your height in inches?\n"))
w = float(input("What is your weight in pounds?\n"))
calculateBMI(h, w)

```

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [March 27, 2024, 6:38pm UTC](https://discuss.python.org/t/how-to-fix-error-missing-2-required-positional-arguments-basic-python/49666/3 "2024-03-27T18:38:41Z")

</div>

Of course I can answer this directly, but I think it is much more valuable to show you the analysis skills that you need to solve problems like this for yourself. My [way to do this](https://en.wikipedia.org/wiki/Socratic_method) is mostly to ask questions - both so that you can see what you already know and don’t know, and start to reason about the gaps; and so that I can understand your exact situation and see if something actually _misled_ you or if your understanding is only _incomplete_.

> [@speedpoet](#):
>
> I did some research and it says height and weight are passing thru to the function, but idk how to resolve it… So I’m not understanding why it would give me this error:

Let’s start here. First off: what do you mean by “it says” - what is “it”? When you are surprised that “it would give me this error” - again, what is “it”? The code that you’ve shown so far doesn’t won’t use the `calculateBMI` code at all - this only explains how to do something (defines a function), but doesn’t request to do it (call it).

The error message that you show, would happen if you have some code somewhere else that says `calculateBMI()`. Is that an accurate understanding of what you actually have?

Then, we can move on to the next part. I can’t really understand what you’re trying to say in the first sentence - it seems like you don’t quite understand what all the words mean, but I can’t tell what you think they mean. In particular, it sounds like you think that passing the values to the function is a bad thing, but it is not. The problem is that the code _doesn’t_ do this, when it _should_.

So the last questions are all about what you understood so far from your research. For example: from what you read, did you see something that explains what an _argument_ to a function is? What did you learn there? (I assume you understand “missing” and “required”, because those are ordinary English words; and “positional” is not really important here.) And, in terms of what calling a function looks like: did you understand that in this code, you are calling _other_ functions - such as `print` and `isinstance` - that were already defined for you?

You may find a useful hint here: when you use `print(height)`, what is accomplished by putting the `height` there? Why would it _not_ work, to just write `print()`, and expect Python to know that the `height` should be printed?
