Skip to main content

Python for Loop

The most common loop in python is the for loop. It's constructed by combining the Python Keywords for and in explained earlier.

For loops are used for sequential traversal. The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects. 

Syntax:

for iterator_var in sequence:
    statements(s)

Example: 

fruits = ['papaya', 'pineapple',  'litchi']
for fruit in fruits:
    print('Current fruit :', fruit)

Output:

Current fruit : papaya
Current fruit : pineapple
Current fruit : litchi
Tags
Submitted by devanshi.srivastava on June 3, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.