Master Python 3 Keywords: The Ultimate Guide

Logan Jul 13, 2026

Python, a high-level, interpreted programming language known for its simplicity and readability, has become a staple in the tech industry. Version 3, released in 2008, brought several improvements and changes, leading many to adopt it over its predecessor. If you're looking to learn or improve your Python skills, understanding keywords introduced or altered in Python 3 is a crucial step.

Minimalist Tech Workspace Ideas
Minimalist Tech Workspace Ideas

The transition from Python 2 to Python 3 was significant, and one of the most notable changes was the handling of print statements. In Python 2, print was a statement, while in Python 3, it's a function. This difference impacts the way you use it in your code and is one of the first keywords you'll encounter in Python 3.

Keywords in python
Keywords in python

Changes in print Functionality

In Python 3, print is used as a function, and you need to enclose the parameters in parentheses. This change allows for more flexibility and control over output formatting.

Most Used Keywords in Python
Most Used Keywords in Python

Here's an example of how to use the print function in Python 3: ```python print("Hello, Python 3!") ```

Keyword args and Additional Features

All Important Python Functions for Beginners (Complete Cheat Sheet)
All Important Python Functions for Beginners (Complete Cheat Sheet)

Python 3's print function also supports several keyword arguments, such as sep, end, and file, which can be used to customize output: ```python print("Hello", "World", sep="-", end="!", file=sys.stdout) ```

Using End and Sep for Custom Formatting

The end parameter allows you to specify what to print at the end of each output. By default, it's a newline character, but you can change it to anything you want. The sep parameter specifies how to separate multiple arguments if you're printing more than one.

Keywords in Python
Keywords in Python

The key takeaway here is that Python 3's print function offers greater control over output formatting, making it a powerful tool for creating clean, efficient code.

Introduction of 'nonlocal' Keyword

Python 3 introduced the 'nonlocal' keyword, which allows you to modify the value of a variable in an enclosing scope, even when it's present in an inner scope with the same name.

List of keywords in python
List of keywords in python

Before Python 3, you could only reference but not modify variables in enclosing scopes, which could lead to confusion and potential bugs. The 'nonlocal' keyword helps avoid these issues by explicitly defining the scope you want to modify.

Using 'nonlocal' in Nested Functions

Python Cheatsheet for Beginners | Learn Python Fast
Python Cheatsheet for Beginners | Learn Python Fast
Keywords and input() using python #coding  #Code #interview #tutorial #VSCode #freshers #2022
Keywords and input() using python #coding #Code #interview #tutorial #VSCode #freshers #2022
a table with words that are used to describe the keywords for each keyword
a table with words that are used to describe the keywords for each keyword
Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know - Be on the Right Side of Change
Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know - Be on the Right Side of Change
Python Cheat Sheet for Beginners
Python Cheat Sheet for Beginners
a computer screen showing the different types of commands and symbols for each type of device
a computer screen showing the different types of commands and symbols for each type of device
an info sheet with the words important method in python, set list and keywords
an info sheet with the words important method in python, set list and keywords
Python Cheat Sheet for Beginners 2026 | Python Basics, Syntax, Loops, Functions & Variables
Python Cheat Sheet for Beginners 2026 | Python Basics, Syntax, Loops, Functions & Variables
an image of what are arg's and kwars in python?
an image of what are arg's and kwars in python?
Emojis in python
Emojis in python
Python Operators Tutorial – Chapter 3 Notes
Python Operators Tutorial – Chapter 3 Notes
Python Keywords
Python Keywords
Client Challenge
Client Challenge
Ultimate Python Cheat Sheet for Beginner
Ultimate Python Cheat Sheet for Beginner
Important Methods in Python
Important Methods in Python
Python Cheat Sheet
Python Cheat Sheet
Python Unit 3 Cheat Sheet 🐍 | Functions, Arguments, Lambda & Modules (AKTU)
Python Unit 3 Cheat Sheet 🐍 | Functions, Arguments, Lambda & Modules (AKTU)
Built in Data types in python
Built in Data types in python
Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know - Be on the Right Side of Change
Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know - Be on the Right Side of Change

Consider the following example in Python 2: ```python def outer(): count = 0 def inner(): count += 1 # This will throw an UnboundLocalError print(count) inner() outer() ```

'nonlocal' in Python 3

In Python 3, you can fix this by using the 'nonlocal' keyword: ```python def outer(): count = 0 def inner(): nonlocal count count += 1 print(count) inner() outer() ```

With 'nonlocal', you can explicitly declare that you want to modify the variable in the enclosing scope, making your code more clear and predictable.

Python 3's introduction of the 'nonlocal' keyword and changes to the print function, among other updates, have significantly improved the language's functionality and adaptability. As Python continues to grow and evolve, staying up-to-date with these changes is crucial for both beginners and experienced developers. So, keep exploring, and happy coding!