Question: I am trying to create a Box2D body, and I need to do it in a function, so I have this very simple function:

```
def create_car():
    my_Car = Car("Interesting parameters"))
    return my_Car
create_car()

```

and then I have this main PyGame loop

```
running = True
while running:
    my_Car.steer()

```

`steer()` as the definition suggests is a method written in class Car
But when I try to run the code this error is raised

```
my_Car() is not defined

```

What am I doing wrong and how can I fix this?
Thank you very much

Answer: 
From your code my\_Car is local variable inside `create_car` function. You have to do something like `my_Car = create_car()`. 

```
 my_Car = create_car()
 running = True
 while running:
     my_Car.steer()

```

First googled link with the explanation: <https://www.techbeamers.com/python-namespace-scope/>
Variables defined inside a function have a local scope, meaning that they cannot be accessed from the outside world of the function. The following should do the trick: 

```
def create_car():
    my_Car = Car("Interesting parameters")
    return my_Car

if __name__ == '__main__':

    car = create_car()

    while True:            
        car.steer()

```