在Python中循环语句只有while一种吗?
来源:3-7 计数器与死循环
qq_焦良_0
2019-10-02 11:15:20
还是有其他的例如for循环之类的,另外在Python中没有自增运算符吗?
while i < 5:
print("hello python")
i = i +1
1回答
①有for循环哦!后续课程老师会讲解的
numList = [1,2,3,4,5,6,7,8,9,10]
i = 1 #计数
for n in numList:
if n % 2 == 0:
print("第{}个偶数{}".format(i,n))
i+=1 #这儿就是用了赋值运算符哦!②赋值运算符有:
+= -= *= /= %=
相似问题