Loading, please wait...

For Loops

A for loop may use for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).

With the help up of the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.

Example

Fruits = ["guava", "banana", "cherry"]
for x in fruits:
  print(x)

Output:

C:\Users\My Name>python demo_for.py
guava
banana
cherry