DEV Community

Kiruthiga S
Kiruthiga S

Posted on

Python

For Loop
used to iterate over sequences such as lists, tuples, strings and ranges


s = "Geeks"
for i in s:
    print(i)
Enter fullscreen mode Exit fullscreen mode

Output:
G
e
e
k
s

for i in range(0, 10, 2):
    print(i)
Enter fullscreen mode Exit fullscreen mode

Output:
0
2
4
6
8

for i in range(1, 4):
    print(i)
else:  
    print("No Break\n")
Enter fullscreen mode Exit fullscreen mode

Output:
1
2
3
No Break

Top comments (0)