"Cecilia Grahn" <[EMAIL PROTECTED]> wrote
> I am trying to make a script which returns a random string:
>
> ch = "So good to see you!","How are you?","Everything good
> today?","Glad you're here!".split(" ")
To python this line has 4 expressions which Pyhon will
assign as a tuple to ch. The first 3 expressions are literal
strings. The fourth is a string which is being split to
form 3 words contained in a list.
So ch winds up containing 3 strings and a list of 3 short
strings.
> everything works pretty much as I want it to, except when the last
> string is returned. It looks like this:
>
> Your name please:Cece
> Hello Cece ['Glad', "you're", 'here!']
So it returns a list of strings as you see here.
In other words you don't need the split operation.
> What is it I have missed or am I using random.choice wrong?
No, you are using split wrongly.
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor