Python的for循环

1、for循环

for i in range(5):
    print(i)

0
1
2
3
4

2、for-else

j = int(input('j='))
for i in range(j):
if i < 3:
print(i)
else:
break
else:
print('yes!')

j=3
0
1
2
yes!

j=5
0
1
2

3、for-continue

j = int (input ('j='))
for i in range (j):
if i == 3:
continue
print(i)

j=5
0
1
2
4

posted @ 2018-01-23 00:24  cross10  阅读(180)  评论(0编辑  收藏  举报