# Scope

*noun*

say it: **“skohp”** **/skoʊp/**

The part of a program where a variable can be used: a variable made inside a function exists only inside that function.

## What is **scope** in Python?

**Scope** is where in the code a variable can be used. A variable made inside a function only exists inside that function.

```python
def checkout():
    total = 40
    print(total)   # works: inside the function

checkout()
print(total)       # NameError: total only exists inside checkout()
```

## In a sentence

- “total was out of **scope** after checkout() ended, so printing it gave a NameError.”
- “Each function's variables have their own **scope**, so two functions can both use a name like price.”

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

- [Scope in C#](https://www.ask-codey.com/glossary/scope-c-sharp)
- [Scope in Java](https://www.ask-codey.com/glossary/scope-java)
- [Scope in JavaScript](https://www.ask-codey.com/glossary/scope-javascript)
- [Scope in PowerShell](https://www.ask-codey.com/glossary/scope-powershell)

Source: https://www.ask-codey.com/glossary/scope
