Thread: Random array
View Single Post
  #1  
Old 09-07-2010, 02:29 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can use one of the functions from Python's random module to generate random numbers and place those in a list. Lists have a sort method you can use to sort the elements within.
Code:
import random
numbers = []
for i in range(1,10):
	number = random.randint(1,10)
	numbers.append(number)
	
print numbers
numbers.sort()
print numbers
Reply With Quote