views:

119

answers:

1

Hi all,

This is probably seriously easy to solve for most of you but I cannot solve this simply putting str() around it can I?

I would like to convert this list: ['A','B','C'] into 'A B C'.

Thanks in advance!!

+8  A: 
In [1]: L = ['A', 'B', 'C']
In [2]: " ".join(L)
Out[2]: 'A B C'
sharth
Thanks so very much!! I knew it was simple but I couldn't figure it out.
+1 but please don't use built-in type/function names, like `list`, to name the variables.
Nick D
Fair point, changed that around. (Although that is one of the things that annoys me about python, that things that I want to consider as reserved words are not).
sharth
@sharth - Most (maybe all) Python editors I've used will use highlight Python's builtins (`list`, `type` and `id` are the ones I want to use most often as variable names) to make it clear that you might want to pick a different name.
Will McCutchen
They aren't reserved words. They are just words with a special meaning.
chpwn