SlideShare a Scribd company logo
Loop tuples
Loop Through a Tuple
You can loop through the tuple
items by using a for loop.
Example:
thistuple = ("apple",
"banana", "cherry")
for x in thistuple:
print(x)
Loop Through the Index Numbers
You can also loop through the
tuple items by referring to their
index number.
Use the range() and len()
functions to create a suitable
iterable.
Example:
thistuple = ("apple",
"banana", "cherry")
for i in
range(len(thistuple)):
print(thistuple[i])
Using a While Loop
You can loop through the tuple items by using
a while loop.
Use the len() function to determine the length
of the tuple, then start at 0 and loop your way
through the tuple items by referring to their
indexes.
Remember to increase the index by 1 after
each iteration.
Example:
thistuple = ("apple", "banana",
"cherry")
i = 0
while i < len(thistuple):
print(thistuple[i])
i = i + 1

More Related Content

Similar to Python Loops, loop methods and types .pptx (20)

PPTX
Tuples in python better understanding with slides
chaudharyaamirm
 
PDF
Tuples in Python
DPS Ranipur Haridwar UK
 
PPT
List.ppt
VIBITHAS3
 
PPTX
Lists_tuples.pptx
M Vishnuvardhan Reddy
 
PPTX
Python Lists is a a evry jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...
KavineshKumarS
 
PPTX
Tuples in Python Object Oriented Programming.pptx
MuhammadZuhairArfeen
 
PPTX
cover every basics of python with this..
karkimanish411
 
PPTX
1.2 - Tuplesforthepythonlearnersino.pptx
IstarthaPD
 
PPTX
PRESENTATION ON TUPLES.pptx
rohan899711
 
PPTX
Data Type In Python.pptx
hothyfa
 
PDF
updated_tuple_in_python.pdf
Koteswari Kasireddy
 
PPT
TUPLE.ppt
UnknownPerson930271
 
PPTX
Lecture 09.pptx
Mohammad Hassan
 
PPTX
Tuple in python
vikram mahendra
 
PDF
014 TUPLES.pdf
amman23
 
PPTX
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
surajnath20
 
PPTX
Python data structures
Harry Potter
 
PPTX
Python data structures
Tony Nguyen
 
Tuples in python better understanding with slides
chaudharyaamirm
 
Tuples in Python
DPS Ranipur Haridwar UK
 
List.ppt
VIBITHAS3
 
Lists_tuples.pptx
M Vishnuvardhan Reddy
 
Python Lists is a a evry jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...
KavineshKumarS
 
Tuples in Python Object Oriented Programming.pptx
MuhammadZuhairArfeen
 
cover every basics of python with this..
karkimanish411
 
1.2 - Tuplesforthepythonlearnersino.pptx
IstarthaPD
 
PRESENTATION ON TUPLES.pptx
rohan899711
 
Data Type In Python.pptx
hothyfa
 
updated_tuple_in_python.pdf
Koteswari Kasireddy
 
Lecture 09.pptx
Mohammad Hassan
 
Tuple in python
vikram mahendra
 
014 TUPLES.pdf
amman23
 
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
surajnath20
 
Python data structures
Harry Potter
 
Python data structures
Tony Nguyen
 

More from AsimMukhtarCheema1 (7)

PPTX
Introduction to python dictionaries .pptx
AsimMukhtarCheema1
 
PPTX
How to add new items in python sets .pptx
AsimMukhtarCheema1
 
PPTX
10 key steps to get a job as a python developer .pptx
AsimMukhtarCheema1
 
PPTX
Python sets an introduction to python sets
AsimMukhtarCheema1
 
PPTX
Joining python tuple and tuple miltiplication.pptx
AsimMukhtarCheema1
 
PPTX
10 Proven Ways to Make Money with Python in 2024 From Beginner to Pro!.pptx
AsimMukhtarCheema1
 
PPTX
Negative indexing of python tuples and indexing range.pptx
AsimMukhtarCheema1
 
Introduction to python dictionaries .pptx
AsimMukhtarCheema1
 
How to add new items in python sets .pptx
AsimMukhtarCheema1
 
10 key steps to get a job as a python developer .pptx
AsimMukhtarCheema1
 
Python sets an introduction to python sets
AsimMukhtarCheema1
 
Joining python tuple and tuple miltiplication.pptx
AsimMukhtarCheema1
 
10 Proven Ways to Make Money with Python in 2024 From Beginner to Pro!.pptx
AsimMukhtarCheema1
 
Negative indexing of python tuples and indexing range.pptx
AsimMukhtarCheema1
 
Ad

Recently uploaded (20)

PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Ad

Python Loops, loop methods and types .pptx

  • 2. Loop Through a Tuple You can loop through the tuple items by using a for loop.
  • 3. Example: thistuple = ("apple", "banana", "cherry") for x in thistuple: print(x)
  • 4. Loop Through the Index Numbers You can also loop through the tuple items by referring to their index number. Use the range() and len() functions to create a suitable iterable.
  • 5. Example: thistuple = ("apple", "banana", "cherry") for i in range(len(thistuple)): print(thistuple[i])
  • 6. Using a While Loop You can loop through the tuple items by using a while loop. Use the len() function to determine the length of the tuple, then start at 0 and loop your way through the tuple items by referring to their indexes. Remember to increase the index by 1 after each iteration.
  • 7. Example: thistuple = ("apple", "banana", "cherry") i = 0 while i < len(thistuple): print(thistuple[i]) i = i + 1