Python Control Flow and Loops (Learning Path) – Real Python
Learning Path ⋅ Skills: Python, Control Flow, Conditional Statements, Booleans, for Loops, while Loops, enumerate, Nested Loops, break, continue, pass
In this learning path, you’ll learn about Python’s control flow tools. Starting with conditional statements and Boolean operators, you’ll move on to for and while loops, enumerate(), nested loops, and loop control keywords like break, continue, and pass.
Python Control Flow and Loops
Learning Path ⋅ 14 Resources
Conditional Statements and Boolean Logic
Start with Python’s conditional statements and Boolean operators. You’ll learn how to control program flow using if/elif/else and the and, or, and not operators.
Course
Python Booleans: Leveraging the Values of Truth
Learn about the built-in Python Boolean data type, which is used to represent the truth value of an expression. You'll see how to use Booleans to compare values, check for identity and membership, and control the flow of your programs with conditionals.
Course
Using the Python and Operator
Learn how Python's "and" operator works and how to use it in your code. You'll get to know its special features and see what kind of programming problems you can solve by using "and" in Python.
Course
Using the Python or Operator
Learn about how the Python or operator works and how to use it. You'll get to know its special features and see what kind of programming problems you can solve by using or in Python.
Course
Using the Python not Operator
Learn how Python's "not" operator works and how to use it in your code. You'll get to know its features and see what kind of programming problems you can solve by using "not" in Python.
for Loops
Learn how to iterate over sequences with for loops. You’ll also use enumerate() for counting and work with nested loops.
Course
For Loops in Python (Definite Iteration)
Learn all about how to perform definite iteration with Python "for" loops. You’ll see how other programming languages implement definite iteration, learn about iterables and iterators, and tie it all together to learn about Python’s for loop.
Course
Looping With Python enumerate()
Once you learn about for loops in Python, you know that using an index to access items in a sequence isn't very Pythonic. So what do you do when you need that index value? In this course, you'll learn all about Python's built-in enumerate(), where it's used, and how you can emulate its behavior.
Tutorial
Nested Loops in Python
Learn how to use nested loops in Python to iterate over multiple sequences and perform repeated actions efficiently in your programs.
while Loops
Explore while loops for repeating tasks based on conditions, and learn how to emulate do-while loops in Python.
Course
Mastering While Loops
Master indefinite iteration using the Python "while" loop. You’ll be able to construct basic and complex while loops, interrupt loop execution with break and continue, use the else clause with a while loop, and deal with infinite loops.
Tutorial
How Can You Emulate Do-While Loops in Python?
Learn how to emulate do-while loops in Python. The most common technique to do this is to create an infinite while loop with a conditional statement that controls the loop and jumps out of it using a break statement.
Loop Control and Membership
Control loop execution with break and continue, test for membership using in and not in, and learn about the pass statement.
Tutorial
The pass Statement: How to Do Nothing in Python
Learn about the Python pass statement, which tells the interpreter to do nothing. Even though pass has no effect on program execution, it can be useful. You'll see several use cases for pass as well as some alternative ways to do nothing in your code.
Congratulations on completing this learning path! You’ve learned how to control program flow in Python using conditional statements, loops, and loop control keywords.
Continue your Python basics journey with the next learning path:
Learning Path
Python Data Structures
23 Resources ⋅ Skills: Python, Strings, Lists, Tuples, Dictionaries, Sets, List Comprehensions, range(), Bytes, Sorting
You might also be interested in these related learning paths: