-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.py
More file actions
71 lines (38 loc) · 1000 Bytes
/
loops.py
File metadata and controls
71 lines (38 loc) · 1000 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#what is loop
#iterate over lists, strings, dicts
#for
# colors = ['Red', 'Blue', 'Green']
#access
# syntax - for val sequence:
# for col in colors:
# print(col)
fruits = "Orange"
# for fruit in fruits:
# print(fruit)
#range() - return a sequence of numbers
# variable_item = range(0,4) # 0...1...2...3
# for i in range(0,4):
# print(i)
#break statements - break and continue....
colors = ['Red', 'Blue', 'Green']
#Example for break()
# #for loop
# #uisng a condition
# #using break statement
# #printing the output
# for col in colors: #loop
# if col == 'Blue': #condition
# break #break statemnet
# print(col) #output
#Example: Continue
#for loop
#uisng a condition
#using break statement
#printing the output
for col in colors: #loop
if col == 'Blue': #condition
continue #break statemnet
print(col) #output
#Nested Lopp
# loop inside loop
# Example of multiplication table