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

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US