Learn Python: Modules/Modules Python Random


Hi! Does anyone know why we need “for i in range(101)” on the following code?
It works perfectly without it, but on the hint it’s said that should be done like this… Any clue?


Import random below:

import random

Create random_list below:

random_list = [random.randint(1,101) for i in range(101)]

Create randomer_number below:

randomer_number = random.choice(random_list)

Print randomer_number below:


Here’s a link to the exercise:



This will cause our program to output 101 random numbers (1…101) in a list.

>>> len(random_list)

That is a list comprehension that inserts one new random integer for each stride of the range.