

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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 is the difference between for...in and for...of loops in JavaScript?
- What is Syntax Tree?
- What are the best practices for using loops in Python?
- What is the syntax for boolean values in MongoDB?
- What is the syntax for lambda expressions in Java?
- What is the syntax of Python if...elif...else statement?
- What is Implementation of Syntax Directed Translators?
- 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 are the basic scoping rules for python variables?
Advertisements