by zekel · 16y ago · 0 comments
import random
boxes = [[] for x in range(10)]
for apple in range(100):
random.choice(boxes).append(apple)
## don't do it like this
# [random.choice(boxes).append(apple) for apple in range(100)]It would be really strange to do
[random.choice(boxes).append(apple) for apple in range(100)]
when even if you wanted to do it on one line the normal syntax works and would be less likely to confuse: for apple in range(100): random.choice(boxes).append(apple)