当前位置:网站首页>Simple distinction between break and continue
Simple distinction between break and continue
2022-06-30 02:11:00 【Cuttlefish a】
break and continue When many people first met , May feel more abstract , It stops the cycle , But I don't know the difference between the two , Now I can show you , What's the difference .
Of course, it's better. You can also try it yourself , Here is the source code .
# Use break Source code
i = 0
while i < 10:
if i == 3:
break
print(i)
i += 1
print(" Don't run away sit back ")
# Use continue Source code
i = 0
while i < 10:
i += 1
if i == 3:
continue
print(i)
print(" Don't run away sit back ")
First Perform use break This code And take a closer look at the output

View output

Find out if Used break after , The result is 3 It will not continue to be implemented , And then exit the cycle .
Take another look at the source code with the same conditions , Use continue What is the difference in the result of stopping the loop .


It can be seen from the results , Same conditions , Used continue Loop aborted , When the cycle comes to 3 when , skip , Continue the cycle except 3 Numbers other than , Not like break, Run to the 3 Directly terminate the loop and exit .
This is used in the loop break and continue The difference between the .
边栏推荐
- 当大学毕业感到迷茫怎么办?
- DTW learning (dynamic time warping) -- Thought and code implementation
- Is the processor the main factor in buying a mobile phone?
- [graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network
- Global communication infrastructure faces apt, robotics and DDoS; The weakest mobile network
- (1) Basic learning - figure out the difference between pin, pad, port, IO and net
- Method of converting songs from DTS to MP3
- scp远程拷贝命令记录
- What is idempotency? Detailed explanation of four interface idempotence schemes!
- 【银河麒麟V10】【桌面】火狐浏览器设置主页不生效
猜你喜欢

UE5的蓝图节点拷贝到UE4后连线和属性值全部丢失了

如何制作CSR(Certificate Signing Request)文件?

33Mysql

Realization of a springboard machine

C language I want to pass

一次 Keepalived 高可用的事故,让我重学了一遍它!

Thinking carefully and fearfully: a software can be transmitted online to monitor whether employees want to "run away"

26.算法常用面试题

【银河麒麟V10】【桌面】火狐浏览器设置主页不生效
![[Galaxy Kirin V10] [desktop] Firefox browser settings home page does not take effect](/img/96/e3afb2b9683cce7645afd483cc0844.png)
[Galaxy Kirin V10] [desktop] Firefox browser settings home page does not take effect
随机推荐
33Mysql
widget使用setImageViewBitmap方法设置bug分析
Scala基础【入门及安装】
8 — router
scp远程拷贝命令记录
Blue Bridge Cup stm32g431 - three lines of code for keys (long press, short press, click, double click)
DDoS extortion attacks: what you need to know
(1) Basic learning - figure out the difference between pin, pad, port, IO and net
Repair method for win10 subsystem WSL if the passwords of root and other users are forgotten
如何制作CSR(Certificate Signing Request)文件?
Conjecture of prime pairs in C language
假离婚变成真离婚,财产怎么办
[Galaxy Kirin V10] [desktop] Firefox browser settings home page does not take effect
Internet Crime Complaint Center reports an increase in DDoS Attacks
Simple implementation of unity object pool
Derivation of univariate polynomial in C language
Jenkins continuous integration environment build 8 (configure mailbox server to send build results)
002_ container
Radware warns about the next round of DDoS Attacks
DHU programming exercise