How do make a function that creates a sequence of n random numbers?

Peter Hansen peter at
Tue Feb 17 21:02:27 CET 2004

shivermetimbers15 wrote:
> I'm new to Python, as you can tell, and I'm interested in how to do this.

1. Go through the Python tutorial step by step.

2. Read the online docs and learn about the "random" module.

3. Write the function using a simple for loop and xrange(), 
   and appending the results of calls to random.randint() to  
   a list, returning the list when you're done.

If you need more help, I suggest you post the code you have written so
far to this mailing list/newsgroup and ask for feedback.  You'll learn
the most, the fastest, this way, and will demonstrate your own willingness
to do some of the work.


More information about the Python-list mailing list