DEV Community

Cover image for Day 16 of documentating my learning journey
James Kabuga
James Kabuga

Posted on

Day 16 of documentating my learning journey

What I learnt Today

1.Learnt while loops and how to impliment them.

On what I Learnt

While loops are a bit different from for loops as one has to create an initializer.

And in a while loop the condition at 1st has to be true so it can print a certain statement.

Also in a while loop it can be used when we don't know the number of times we want to iterate.

At the end we have to specify if we want to increment or decrement depending on what we want to achieve.

We apply incrementation or decrementation by reassigning the varible.

Syntax for a while-loop:

Count =0
while condition:
Do sth
Count += 1 or Count -= 1

Count =0 is the initalizer
Count +=1 is reassigning the variable.

I wrote a python script that prints even numbers between 1 and 20

Resources I used

A python refresher series by Bonaventure Ogeto

Github for documentating my learning journey in python.

What's Next

Tomorrow I'll learn how to impliment break and continue statements

Top comments (0)