# Local Variable

*noun*

say it: **“LOH-kul VAIR-ee-uh-bul”** **/ˈloʊkəl ˈvɛəriəbəl/**

A variable created inside a function; it exists only while that function runs, and the rest of the program can't see it.

## What is a **local variable**?

A **local variable** is created inside a function. It exists only while that function runs, and the rest of the program can't see it.

```python
def add_tax(price):
    tax = price * 0.07   # local to add_tax
    return price + tax

print(add_tax(100))  # 107.0
```

## In a sentence

- “Printing a **local variable** outside its function gives a NameError.”
- “tax is a **local variable** inside add_tax.”

Level: Apprentice · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=2)

Updated: November 19, 2026

## In other subjects

- [Local Variable in C#](https://www.ask-codey.com/glossary/local-variable-c-sharp)
- [Local Variable in Java](https://www.ask-codey.com/glossary/local-variable-java)
- [Local Variable in Unix](https://www.ask-codey.com/glossary/local-variable-unix)

Source: https://www.ask-codey.com/glossary/local-variable
