What is Python For Loop condition explain with examples. When to use and how to use For Loop in Python code. Difference between While and For Loop.

Python for BEGINNERS and DUMMIES

Reusable Define Function with Return


Python 2D Lists and Nested Loops Examples


Python exception handling using
try except with examples


Python For Loop condition with examples


Python while condition with examples


Python if elif else logical condition


Python Tuples vs List


Python Translator with Examples


Python List Functions with Examples


Data Structures and Data Types


Python Exponent Function with examples


Python dictionary with examples


Variables, Expressions & Statements


List of 'Reserved Words' in Python


Boolean Expressions &
Comparison Operators

Python For Loop Condition Definition:


When there is a need to loop through a set of things such as a list of words (or) the lines in a file. In this case we can construct a definite loop using a for statement.

The key difference between ‘While’ condition and ‘For Loop’:


while statement is an indefinite loop because it simply loops until some condition becomes False.

for loop is looping through a known set of items so it runs through as many iterations as there are items in the set.

Example 1:
friends = ["John", "Kevin", "Karen"]
for friend in friends:
===>print(friend)


Result:
John
Kevin
Karen


Example 2:
for index in range(10):
===>print(index)


Result:
0
1
2
3
4
5
6
7
8
9


Example 3:
for index in range(5, 10):
===>print(index)


Result:
5
6
7
8
9


Example 4:
friends = ["John", "Kevin", "Karen"]
for index in range(len(friends)):
===>print(friends[index])


Result:
John
Kevin
Karen


Python Interview Questions and
Answers


What are the differences between
Python 2.x vs Python 3.x
(2.7 vs 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9),
when to you which version ?


What is Python Variable, Expression
and Statement ?


What is a 'Reserved Word' in Python ?
List of Reserved words in Python ?

How to Install Python, IDE, UI
to Practice


Download and Install Python from
Python.org


Download and Install Anaconda to Use
SPIDER and Jupyter Notebook