|
|
|
|
|
by JeremyBanks
5899 days ago
|
|
List comprehensions are wonderful, but in his example it's not being used to generate an actual list (each .append() will return None), just as a strange alternate format for a for loop. 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)
|
|