0% found this document useful (0 votes)
27 views

Unit2 - Iterating by Subsequence Index

This document discusses iterator loops in Python. Iterator loops iterate once for each item in a list or data structure rather than using a counting loop. In Python, an iterator loop uses the syntax "for <var> in <range>" where <range> is a tuple or range function providing the items to iterate over, allowing the loop to iterate once per item in the provided sequence.

Uploaded by

Deepak Kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Unit2 - Iterating by Subsequence Index

This document discusses iterator loops in Python. Iterator loops iterate once for each item in a list or data structure rather than using a counting loop. In Python, an iterator loop uses the syntax "for <var> in <range>" where <range> is a tuple or range function providing the items to iterate over, allowing the loop to iterate once per item in the provided sequence.

Uploaded by

Deepak Kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit 2 Basic Python

Iterating by subsequence index


Iterator Loops
• A variation of the counting loop is a loop that iterates
once for each item in the list (or data structure)
provided
• Python: for <var> in <range>:
• <range> will be a tuple or range(value [, value] [, value])
• note that Python’s for loop can also be a counting loop by using the
range function as in for x in range(0, 10, 2) which iterates over 0, 2, 4,
6, 8, 10

You might also like