snake case

In programming, snake case is a naming convention where you write compound names by joining words with underscores (_) and using only lowercase letters.

Using underscores to separate words in an identifier improves readability. Python follows snake case for variable, function, and module names.

Example

Here’s an example of snake case in action:

Python
first_name = "John"
light_speed = 299_792_458

def get_user_list():
    """Returns a list of users."""
    ...

def calculate_total():
    """Calculates the total amount."""
    ...

In these examples, underscores separate words, making the identifiers easier to read. Lowercase letters are another characteristic of the snake case naming convention.

Tutorial

How to Write Beautiful Python Code With PEP 8

Learn how to write high-quality, readable code by using the Python style guidelines laid out in PEP 8. Following these guidelines helps you make a great impression when sharing your work with potential employers and collaborators.

intermediate best-practices

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated March 6, 2025 • Reviewed by Martin Breuss