-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforLoop.py
More file actions
17 lines (15 loc) · 758 Bytes
/
forLoop.py
File metadata and controls
17 lines (15 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
for i in range(5):
print("loop iteration:", i)
# This code demonstrates the use of a for loop in Python.
# It iterates over a range of numbers from 0 to 4 and prints the current iteration number.
for i in range(5):
print("loop iteration:", i + 1)
# This code demonstrates the use of a for loop in Python.
# It iterates over a range of numbers from 0 to 4 and prints the current iteration number incremented by 1.
# The output will be 1 to 5 instead of 0 to 4.
name_list = ['John', 'Doe', 'Jane']
for name in name_list:
print("Hello", name)
# This code demonstrates the use of a for loop to iterate over a list of names.
# It prints a greeting message for each name in the list.
# The output will be "Hello John", "Hello Doe", and "Hello Jane".