for Loop in Python Programming
In this lesson, we will learn what is for loop, and how many ways a for loop can be used.
What is for Loop
The for loop is a control structure that allows us to repeat a block of code a specific number of times. The for loop is particularly useful when we know how many times we want to execute a statement or a block of statements.
In Python, for loop can be used in a list, tuple, set, string, etc.
for x in sequence:
# Code to be executed
Here, x is a variable that takes values from a sequence. A sequence can be a list, tuple, set, string, or generated using the range() function.
Unlock This Lesson & Start Learning!
Get full access to this lesson, practical exercises, quizzes, and your Mentora AI Tutor.
Special Offer, use coupon code DWL6BC to get additional discount of 10% on all subscription. Hurry limited time offer.
1 Month
Renews at ₹259/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor
3 Months
Equivalent to ₹219.67/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor
6 Months
Equivalent to ₹193.17/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor
12 Months
Equivalent to ₹179.92/month.
Manual renewal required.
No automatic charges.
- Premium lessons access
- Quizzes and exercises
- Mentora AI Tutor