list(x for x in range(1,100,2) if x<50)
短不代表简单
你这种写法别人看见要打死你..
L=list(range(1,100,2)) n=1 while n<=50: print(L) n=n+2 这样是对的吗?
你的写法并不对
L=[] n=1 while n<=50: L.append(n) n=n+2 print(L)
re:#3
你这样写的效果是打印25遍列表[1,3,5,7,...,99] =。= 6
Sign in to make a reply
手机用户1854970634
list(x for x in range(1,100,2) if x<50)