Python For Loop Syntax and Examples

In computer science, a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly.

Table of Contents
Syntax

for item in sequence:
    execute expression
Examples

Basic:

for i in range(1,6):
    print(i)

Enumerate:

items = ["apple","banana","egg"]

for index, item in enumerate(items):
    print(index,item)

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.