0% found this document useful (0 votes)
5 views2 pages

Control Statements

Python control statements
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Control Statements

Python control statements
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Loop Control Statements

Loop control statements change execution from its normal sequence. When
execution leaves a scope, all automatic objects that were created in that scope are
destroyed. Python supports the following control statements.

Continue , break and pass

Continue--> It returns the control to the beginning of the loop.

for x in 'python developer':


if x == 'e' or x == 'o':
continue
print('Current Letter :', x)

Output will be each letter in python developer but without e and o. they continue
even after that.
151
Break--> It brings control out of the loop.
for x in 'python developer':
# break the loop as soon it sees 'e' or 'o'
if x == 'o' or x == 'e':
break
print('Current Letter :', x )
Output will be ‘o’ , because it will stop looping after it sees o or e.
Pass -->We use pass statement to write empty loops. Pass is also used for
empty control statements, function and classes.
for x in “python developer”:
Pass
Print(“last letter:”,x)
Output will be the last letter of the word which is ‘r’.
152

You might also like