Repository navigation
Expand file tree
/
Copy path052-Continue-Statement.py
More file actions
65 lines (53 loc) · 2.12 KB
/
Copy path052-Continue-Statement.py
File metadata and controls
65 lines (53 loc) · 2.12 KB
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
"""
===============================================================================
Continue Statement
===============================================================================
Program Description:
--------------------
This program demonstrates the use of the continue statement in Python.
The continue statement is used to skip the current iteration of a loop
and continue with the next iteration.
Syntax:
continue
Author : Shaik Mahaboob Basha
Repository : 13-Python
File Name : 52-Continue-Statement.py
===============================================================================
"""
# -----------------------------------------------------------------------------
# Displaying a heading.
# -----------------------------------------------------------------------------
print("Continue Statement Example")
# Output: Continue Statement Example
# -----------------------------------------------------------------------------
# Using a for loop to display numbers.
# -----------------------------------------------------------------------------
for number in range(1, 11):
# -------------------------------------------------------------------------
# Checking whether the current number is equal to 6.
# -------------------------------------------------------------------------
if number == 6:
# ---------------------------------------------------------------------
# Skipping the current iteration when the condition becomes True.
# ---------------------------------------------------------------------
continue
# -------------------------------------------------------------------------
# Displaying the current number.
# -------------------------------------------------------------------------
print(number)
# Output:
# 1
# 2
# 3
# 4
# 5
# 7
# 8
# 9
# 10
# -----------------------------------------------------------------------------
# Displaying a message after the loop.
# -----------------------------------------------------------------------------
print("Program Completed.")
# Output:
# Program Completed.