-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfor_loop.py
More file actions
51 lines (34 loc) · 877 Bytes
/
for_loop.py
File metadata and controls
51 lines (34 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# For Loop = Interate over sequence (Ku soo cel celi waxyaabo)
# fruits = ["Apple", "Banana", "Cherry"]
# for item in fruits:
# print(item)
# Loop over a string
# for x in "banana":
# print(x)
# Break and Continue
# fruits = ["Apple", "Banana", "Cherry"]
# for x in fruits:
# print(x)
# if x == "Banana":
# print("Found")
# break
# for x in fruits:
# print(x)
# if x == "Banana":
# print("Found")
# continue
# Range
# for x in range(6):
# print(x)
# for x in range(1, 20, 3):
# print(x)
# Nested for loop
# colors = ["Red", "Yellow", "Orange"]
# fruits = ["Apple", "Banana", "Cherry"]
# for x in colors:
# for y in fruits:
# print(x, y)
# Enumerate - Counter - Build-in Function
fruits = ["Apple", "Banana", "Cherry"]
for counter, x in enumerate(fruits):
print(counter, x)