-
Notifications
You must be signed in to change notification settings - Fork 0
/
13.break-continue-pass.py
46 lines (42 loc) · 1.74 KB
/
13.break-continue-pass.py
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
<<<<<<< HEAD
#break statement inside a nested loop (loop inside another loop), break will terminate the innermost loop.
for val in "string":
print("Inside for loop")
if val == "t":
print("since if condition is success going to exit from entire loop")
break
print(val)
print("Exited from for loop")
# continue statement is used to skip the rest of the code inside a loop for the current iteration only.
for val in "string":
if val == "i":
print("Since if statement gt success skipping print and going back to for loop")
continue
print(val)
print("The end")
#we have a loop or a function that is not implemented yet, but we want to implement it in the future. But the body cannot be empty
#So, we use the pass statement to construct a body that does nothing.
sequence = {'p', 'a', 's', 's'}
for val in sequence:
=======
#break statement inside a nested loop (loop inside another loop), break will terminate the innermost loop.
for val in "string":
print("Inside for loop")
if val == "t":
print("since if condition is success going to exit from entire loop")
break
print(val)
print("Exited from for loop")
# continue statement is used to skip the rest of the code inside a loop for the current iteration only.
for val in "string":
if val == "i":
print("Since if statement gt success skipping print and going back to for loop")
continue
print(val)
print("The end")
#we have a loop or a function that is not implemented yet, but we want to implement it in the future. But the body cannot be empty
#So, we use the pass statement to construct a body that does nothing.
sequence = {'p', 'a', 's', 's'}
for val in sequence:
>>>>>>> 67b0bcef29fcd49d9c0e591008d5592b54882303
pass