Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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.
You can use list comprehension:
List = [randint(0,99) for i in range(20)]
Add a comment
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!
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.