forked from josephyuan/python-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.py
More file actions
34 lines (27 loc) · 495 Bytes
/
loop.py
File metadata and controls
34 lines (27 loc) · 495 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# range(start, stop[, step])
for i in range(5):
print i;
print '==============';
for i in range(0,5,2):
print i;
print 20 * '*';
for i in [0, 1, 2]:
print i;
# one line loop~ cool~
arr = [-num for num in range(20) if num % 3 == 1];
print arr;
print 10 * '*', 'for end', 10 * '*';
i = 0;
while i < 5:
print i;
i+=1;
print 20 * '*';
i = 0;
while True:
if i >= 5:
break;
else:
i+=1;
if i % 2 == 1:
continue;
print i;