DEV Community

Cover image for Day 17 of documenting my learning journey
James Kabuga
James Kabuga

Posted on

Day 17 of documenting my learning journey

What I did today
1.Learnt how to impliment break and continue statements in python.
2.Tracked committed and pushed everything to Github

On what I learnt Today

Break statement is used when we want to 'break' from a certain loop when a certain cindition is met.
Break statement mostly used in a while loop.

A loop such as

while true:
Block of code
break

That kind of loop would never stop iterating unless we use a break statement to indicate that when that condition is met we stop the iteration.

Continue statement is used to skip a certain line of code.

Example

i = 0

while i <= 10:
if i == 7:
i += 1
continue
print(i)
i += 1

In this loop we will be printing numbers 0 to 10 but at 7 we will skip printing 7 because of the continue statement.

Resources I used
1.Python refresher series by Bonaventure Ogeto
2.Github for documenting the python series journey by pushing to public repo python-concepts

What's Next
I'll be building a number guessing game to compliment what I have learnt on that week

Top comments (0)