Skip to content

Commit ce043d3

Browse files
committed
fix issue #25
1 parent 9c086fb commit ce043d3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,8 @@ if __name__ == "__main__":
671671
X是 generator类型
672672
## 4.10 请用一行代码 实现将1-N 的整数列表以3为单位分组
673673
```
674-
print ([[x for x in range(1,100)] [i:i+3] for i in range(0,len(list_a),3)])
674+
N =100
675+
print ([[x for x in range(1,100)] [i:i+3] for i in range(0,100,3)])
675676
```
676677
## 4.11 Python中yield的用法》
677678
yield就是保存当前程序执行状态。你用for循环的时候,每次取一个元素的时候就会计算一次。用yield的函数叫generator,和iterator一样,它的好处是不用一次计算所有元素,而是用一次算一次,可以节省很多空间,generator每次计算需要上一次计算结果,所以用yield,否则一return,上次计算结果就没了

0 commit comments

Comments
 (0)