W3docs

What is the naming convention in Python for variable and function?

In Python, variable and function names should be lowercase, with words separated by underscores.

In Python, variable and function names should be lowercase, with words separated by underscores. For example:

Naming convention in Python

my_variable = "Hello, world!"

def my_function():
    print("This is my function.")
Info

Watch a video course: Python - The Practical Guide

Additionally, variable and function names should be descriptive and meaningful, in order to make the code more readable and easier to understand.