[Tutor] random.choice function

Cecilia Grahn cissi85 at gmail.com
Sat Jan 19 12:37:22 CET 2008


Hi,
this is my first mail and I apologize if I got something wrong =)
I am trying to make a script which returns a random string:

#hello.py
# Get the user's name and print a friendly hello
import random, string
name = raw_input("Your name please:")
ch = "So good to see you!","How are you?","Everything good  
today?","Glad you're here!".split(" ")
x = random.choice(ch)
print "Hello", name, x

everything works pretty much as I want it to, except when the last  
string is returned. It looks like this:

 >>> ================================ RESTART  
================================
 >>>
Your name please:Cece
Hello Cece ['Glad', "you're", 'here!']
 >>>

What is it I have missed or am I using  random.choice wrong?


/CeCe


More information about the Tutor mailing list