CONTINUE in Python WHILE Loops - Python Tutorial for Beginners

Опубликовано: 07 Март 2021
на канале: Digital Academy
422
8

🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!

🖥️ CONTINUE in Python WHILE Loops

The Python CONTINUE statement, on the other hand, will immediately terminate the current loop iteration. The execution jumps to the top of the loop and re-evaluate the expression, to determine whether the loop will execute again with the next iteration, or if it will terminate and proceed to the first statement following the loop.

while expression is True:
statement_1
statement_2
if condition is True:
continue
...
statement_3
...
following_statement


Let's have a look at the same example you have seen, in the break statement. But, instead of break in Python, you will now use the CONTINUE statement. Continue is also a control statement in Python, but the only difference is that it will only skip the current iteration in the loop, continues with the next iteration - then executes the rest of the iterations anyway, until the while condition becomes False

colours = ['red', 'green', 'blue', 'yellow']

while colours:
colour = colours.pop()
if colour == 'blue': continue
print(colour)

In the above example, as soon as the loop encounters the item 'blue', it will enter the if statement block, where the continue statement will skip the current item in the loop, then continues to the next iteration, with the item yellow. This, loop will repeat until it reaches the lat item of the sequence, and result in printing out 'red', 'green' and 'yellow' - since blue has been skipped over.

Let's play this video, stick around and watch until the end of this video! 👍🏻

Digital Academy™ 🎓

***

☞ WATCH NEXT:
○ Data Types in Python -    • DATA TYPES in Python (Numbers, String...  
○ Operators in Python -    • OPERATORS in Python (Arithmetic, Assi...  
○ IF Statements in Python -    • CONDITIONAL Statements in Python (IF,...  
○ FOR Loops in Python -    • FOR Loop in Python (Syntax, Break, Co...  

📖 Blog: http://digital.academy.free.fr/blog

📖 [FULL Course] HOW TO Learn Python? Python Tutorial for Beginners:    • 🐍 Python 101: Learn Python Basics for...  

📖 [PLAYLIST] Complete Python Development Course for Beginners: http://digital.academy.free.fr/playli...

🧑‍🎓 [COURSE] http://digital.academy.free.fr/courses

📘 [BOOK] Python for Absolute Beginners: https://amzn.to/3NvyOWV

🛒 Shopping and Discounts: http://digital.academy.free.fr/store

💌 Weekly Newsletter for Developers: https://www.getrevue.co/profile/digit...

#Python #Tutorial #Beginners #Shorts

***

♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.

***

♡ FOLLOW US ♡
✧ http://digital.academy.free.fr/
✧   / digitalacademyy  
✧   / digitalacademyfr  
✧   / digital_academy_fr  
✧    / digitalacademyonline  

♡ SUPPORT US ♡
✧ http://digital.academy.free.fr/join
✧ http://digital.academy.free.fr/store
✧ http://digital.academy.free.fr/donate
✧ http://digital.academy.free.fr/subscribe
✧   / digital_academy  
✧ https://www.buymeacoffee.com/digital_...

***


На этой странице сайта вы можете посмотреть видео онлайн CONTINUE in Python WHILE Loops - Python Tutorial for Beginners длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Digital Academy 07 Март 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 422 раз и оно понравилось 8 зрителям. Приятного просмотра!