easy question about join method

N

nephish

i have seen the join method before, mostly in this group and i want to
get it a little better.

if i have a list

x = ['this','is','a','sentence','held','in','a','list']

how can i make it print as a single string? or make a single string out
of it ?

thanks
 
J

Jorge Godoy

nephish said:
i have seen the join method before, mostly in this group and i want to
get it a little better.

if i have a list

x = ['this','is','a','sentence','held','in','a','list']

how can i make it print as a single string? or make a single string out
of it ?

print ' '.join(x)
 
N

nephish

yep, easy enough

thanks

-shawn


Jorge said:
nephish said:
i have seen the join method before, mostly in this group and i want to
get it a little better.

if i have a list

x = ['this','is','a','sentence','held','in','a','list']

how can i make it print as a single string? or make a single string out
of it ?

print ' '.join(x)
 
T

Terry Reedy

The easy way to get one answer for buildin funcs and methods is the help
function in the interactive interpreter (and Idle's and probably other
imitations thereof) is, for example,
Help on method_descriptor:

join(...)
S.join(sequence) -> string

Return a string which is the concatenation of the strings in the
sequence. The separator between elements is S.

To remind how to use 'help', 'help' is more informative than 'help(help)'
;-)

Terry Jan Reedy
 
N

nephish

very helpful indeed.
i did a help([]) to see if it would give me anything for a list.
wow.
thanks a lot.

-sk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top