python 示例_Python | 演示继续声明的示例

python 示例

continue is a keyword in python just like another programming language and it is used to send the program’s section to loop by escaping the execution of next statement in the loop.

就像另一种编程语言一样, continue是python中的一个关键字,它用于通过转义循环中next语句的执行来将程序的部分发送到循环中。

In the given example, loop is running from 1 to 10 and we are using the continue statement if value of ‘i’ is 6. This when the value of i will be 6, program’s execution will continue without prating the 6.

在给定的示例中,循环从1到10运行,并且如果'i'的值为6,我们将使用continue语句。这在i的值为6时,程序的执行将继续进行而不会分页6。

Example 1:

范例1:

for i in range(1,11):
    if(i==6):
        continue
    print(i)

Output

输出量

1
2
3
4
5
7
8
9
10

Example 2: In this example, we are printing character by character of the value/string “Hello world” and continuing the loop execution, if the character is space.

示例2:在此示例中,如果字符为空格,则按字符/值/字符串“ Hello world”打印字符,并继续执行循环。

for ch in "Hello world":
    if ch == " ":
        continue
    print(ch)

Output

输出量

H
e
l
l
o
w
o
r
l
d


翻译自: https://www.includehelp.com/python/continue-statement-example.aspx

python 示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值