FAQ: Modules: Python - Modules Python Random


This community-built FAQ covers the “Modules Python Random” exercise from the lesson “Modules: Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise Modules Python Random

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


what’s the difference between:

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


random_list = [random.randint(1,101)]


If you’re asking about code that uses feature you know nothing about, then the reasonable answer is to go learn that feature isn’t it?

Or, if you do know what each thing there does, would you still argue that they’re equivalent? If so, what is that argument?

There are several things in those pieces of code. Since they both use random, perhaps it has nothing to do with random and perhaps you could instead replace it with a simpler value, like 0:

a = [0 for i in range(101)]
b = [0]