Python Control Flow and Loops
Learning Path ⋅ Skills: Python, Control Flow, for Loops, while Loops, break, continue, Context Managers
![Python "while" Loops (Indefinite Iteration)](https://files.realpython.com/media/Python-while-Loops-Indefinite-Iteration_Watermarked.2dfa40d8e92c.jpg)
Explore Python control flow and loops to master conditional statements, Boolean operators (and
, or
, not
), for
and while
loops, emulate do-while loops, use in
and not in
for membership, and understand control flow keywords such as pass
, break
, and continue
, and use context managers through Python’s with
statements. Dive in!
Python Control Flow and Loops
Learning Path ⋅ 11 Resources
![Title image for Conditional Statements in Python (if/elif/else) (Conditional Statements in Python)](https://files.realpython.com/media/Conditional-Statements-in-Python_Watermarked.b6b7d30ff62b.jpg)
Course
Conditional Statements in Python (if/elif/else)
Learn how to work with conditional ("if") statements in Python. Master if-statements step-by-step and see how to write complex decision making code in your programs.
![Title image for Python Conditional Statements (Conditional Statements in Python)](https://files.realpython.com/media/Conditional-Statements-in-Python_Watermarked.b6b7d30ff62b.jpg)
Interactive Quiz
Python Conditional Statements
![Title image for Python Booleans: Leveraging the Values of Truth (Python Booleans: Optimize Your Code With Truth Values)](https://files.realpython.com/media/What-is-a-Python-Boolean_Watermarked.ba6413996cb3.jpg)
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.
![Title image for Using the Python and Operator (Using the "and" Boolean Operator in Python)](https://files.realpython.com/media/The-Python-and-Operator_Watermarked.e2b7fbb273b9.jpg)
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.
![Title image for Using the Python or Operator (How to Use the Python or Operator)](https://files.realpython.com/media/The-Python-OR-Keyword_Watermarked.18e16a4721d8.jpg)
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.
![Title image for Using the Python not Operator (Using the "not" Boolean Operator in Python)](https://files.realpython.com/media/Pythons-not-Keyword_Watermarked.d80a58b5e06d.jpg)
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.
![Title image for For Loops in Python (Definite Iteration) (Python "for" Loops (Definite Iteration))](https://files.realpython.com/media/Python-for-Loops-Definite-Iteration_Watermarked.9c0d36b6de30.jpg)
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.
![Title image for Python "for" Loops: The Pythonic Way (Python for Loops: The Pythonic Way)](https://files.realpython.com/media/UPDATE-Python-for-Loops-Definite-Iteration_Watermarked.32bfd8825dfe.jpg)
Interactive Quiz
Python "for" Loops: The Pythonic Way
![Title image for Mastering While Loops (Python "while" Loops (Indefinite Iteration))](https://files.realpython.com/media/Python-while-Loops-Indefinite-Iteration_Watermarked.2dfa40d8e92c.jpg)
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.
![Title image for Python "while" Loops (Python "while" Loops (Indefinite Iteration))](https://files.realpython.com/media/Python-while-Loops-Indefinite-Iteration_Watermarked.2dfa40d8e92c.jpg)
Interactive Quiz
Python "while" Loops
![Title image for How Can You Emulate Do-While Loops in Python? (How Can You Emulate Do-While Loops in Python?)](https://files.realpython.com/media/Emulating-a-do-while-Loop-in-Python_Watermarked.80ad40007b07.jpg)
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.
![Title image for Python's "in" and "not in" Operators: Check for Membership (Python's "in" and "not in" Operators: Check for Membership)](https://files.realpython.com/media/Membership-Operators-in-Python-in-and-not-in_Watermarked.f22635242e8d.jpg)
Tutorial
Python's "in" and "not in" Operators: Check for Membership
Learn how to check if a given value is present or absent in a collection of values using Python's in and not in operators, respectively. This type of check is known as membership test in Python.
![Title image for The pass Statement: How to Do Nothing in Python (The pass Statement: How to Do Nothing in Python)](https://files.realpython.com/media/The-Python-pass-statement-With-Examples_Watermarked.fa3be5d1bf65.jpg)
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.
![Title image for Context Managers and Using Python's with Statement (Context Managers and Python's with Statement)](https://files.realpython.com/media/Context-Managers--the-Python-with-Statement_Watermarked.3774ffbe2514.jpg)
Course
Context Managers and Using Python's with Statement
Learn what the Python with statement is and how to use it with existing context managers. You'll also learn how to create your own context managers.
![Title image for Context Managers and Python's with Statement (Context Managers and Python's with Statement)](https://files.realpython.com/media/Context-Managers--the-Python-with-Statement_Watermarked.3774ffbe2514.jpg)
Interactive Quiz
Context Managers and Python's with Statement
Got feedback on this learning path?
Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!