# Global Variable

*noun*

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

A variable created outside any function, so code anywhere in the file can read it; changing one inside a function takes the global keyword.

## What is a **global variable**?

A **global variable** is created outside any function, so code anywhere in the file can read it. Changing one from inside a function takes the `global` keyword, so it's usually better to pass values in and return them.

```python
STORE_NAME = "Corner Cafe"

def print_receipt():
    print(f"Thanks for visiting {STORE_NAME}")

print_receipt()  # Thanks for visiting Corner Cafe
```

## In a sentence

- “STORE_NAME is a **global variable** every function can read.”
- “Passing the total in and returning it beats changing a **global variable**.”

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

- [Global Variable in Unix](https://www.ask-codey.com/glossary/global-variable-unix)

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