Divide elements of a list by integer with list comprehension: index out of range
问题 I am trying to divide all the elements of a list filled with integers by another integer (functionality like in numpy arrays) by list comprehension, like so: results = 300 * [0] for i in range(100): for j in range(300): results[j] += random.randrange(0,300) average_results = [results[x] / 100 for x in results] However, if I run this in Python, it throws an IndexError: list index out of range I have worked around this by using a regular for loop: average_results = [] for x in results: average