
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
What is basic syntax of Python for Loops?
Python's for loop executes the body of loop for each object in a collection such as string, list, tuple or dictionary. Its usage is as follows −
Example
for obj in seq: stmt1 stmt2
Following code snippet iterates over each number element of the list and prints its square
L1=[1,2,3,4,5] for x in L1: print (x*x)
Output
The output will be
1 4 9 16 25
- Related Articles
- What is basic syntax of Python if...else statement?
- What is the basic syntax to access Python Dictionary Elements?
- What is syntax of tuple declaration in Python?
- What is correct syntax of Python if statement?
- What are the best practices for using loops in Python?
- What is python .. ("dot dot") notation syntax?
- What is the difference between for...in and for...of loops in JavaScript?
- What is the syntax of Python if...elif...else statement?
- What is correct syntax to create Python tuples?
- What is correct syntax to create Python lists?
- What is correct syntax to create Python dictionary?
- What is the syntax for boolean values in MongoDB?
- What is the syntax for lambda expressions in Java?
- What are the basic scoping rules for python variables?
- What is Syntax Tree?

Advertisements