0
from random import randint

List = [randint(0,99)*20]
print(List)

How could i go along the lines of make it into a list for 20 different random numbers between 0 and 99? The code i have ends up multiplying one random number 20 times.

2 Answers 2

1

You can use list comprehension:

List = [randint(0,99) for i in range(20)]
Sign up to request clarification or add additional context in comments.

Comments

0
from random import randint

List = [randint(0,99) for i in range(20)]
print("%3s" % List)
List.sort()
print("%3s" % List)

My primary is Java. I hope this helps!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.