[Tutor] Idle
Christopher Marlett
cmarlett at luc.edu
Fri Mar 14 01:44:25 CET 2008
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.
More information about the Tutor
mailing list