python_interview_question icon indicating copy to clipboard operation
python_interview_question copied to clipboard

88一行代码有误,结果多另一个空list,可以更改为:

Open wangzaistone opened this issue 5 years ago • 0 comments

原代码与结果为: N =100 print ([[x for x in range(1,100)] [i:i+3] for i in range(0,100,3)]) [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12],... [97, 98, 99], []] =100 可以更改为: s=[[ m for m in range(j+1,j+4)] for j in [ i for i in range(0,97,3)]] print(s)

wangzaistone avatar Oct 28 '19 11:10 wangzaistone