Using break and continue with while
using break and continue with why a loo break can continue can be used in both for and while.
Break can be used to exit the while loop immediately.
Easiest definition for continue with this cap and return back to the beginning to the loop.
Let's see how we can now go to practice.
I will show you how to use break first and then continue for example create a variable called I equal
1.
Create an empty variable user equal empty string then use while I is less than or equal five.
Call use a variable equal input Prentice's insert and in a backslash and then print a string you inserted
last use variable OK.
Now if user equal equal is Tsering John Kallen then Taieb the keyword break.
So break here means if the user inserted the name of John it will exit the loop immediately and then
type.
Elif.
User.
Equal equal is string my colon and type.
The keyword continue continue means if the user answered to Mike the program will skip that return back
to the table of the condition then type I plus equal 1 which means incremented by 1 each time the load
is low.
After that try the code and trim
Akeem I will put multiple names to show you.
Watch out
as you can see when inserted.
John Uloom start now.
I will use the term no one more time with multiple names.
OK when I inserted it is escape when I inserted John.
It is not that simple a thing for now.
Thanks for watching.