Aug. 30, 2023, 2:35 p.m. | Akash Singh

DEV Community dev.to

Loops allow you to repeat certain actions multiple times. The for loop and the while loop are commonly used in Python.





Table of Contents



  1. The for Loop

  2. The while Loop

  3. Loop Control Statements

  4. Nested Loops

  5. Looping Through Iterables





1. The for Loop


The for loop is used to iterate over a sequence (such as a list, tuple, string, or range) and execute a block of code for each element in the sequence.





Syntax:



for element in sequence:
# Code …

basic beginners contents control iterables iterate loop multiple programming python table through tutorial

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Senior Machine Learning Engineer (MLOps)

@ Promaton | Remote, Europe

Director, Clinical Data Science

@ Aura | Remote USA

Research Scientist, AI (PhD)

@ Meta | Menlo Park, CA | New York City