[Tutor] Idle
Bartruff, Pamela J.
Pamela.J.Bartruff at supervalu.com
Fri Mar 14 13:16:08 CET 2008
I'm very new to Python, but it seems like I just learned in a class for
a random number, you would need the :
import random
-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Christopher Marlett
Sent: Thursday, March 13, 2008 7:44 PM
To: tutor at python.org
Subject: [Tutor] Idle
Hi, I'm trying to write a program that uses the range function to
produce and then print [1, 2, 3, 4]. then prompt the user for an integer
n and print the list [1, 2, 3, ... , n] - including n. Then use a simple
repeat loop to print five randomly chosen numbers from the range [1, 2,
3, ... , n]
This is what I have done so far
print [1,2,3,4]
nstring = raw_input("Enter any number: ")
n = int(nstring)
print range(1,n+1)
y = random.randrange(1,n)
print y
It all works up until I need to print five randomly chosen numbers from
the range [1,n]. It tells me that random is not defined.
Thank you for your time.
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list