469,270 Members | 1,120 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Some help with strings


I am just wondering if anyone can tell me how to do this :

Say I have a list like this :

listA = ['c','c','c','c','c','c']

and I want to print out the contents but I don't want to square brackets .... for example if I do :

print listA

I get ----> ['c','c','c','c','c','c']

But I just want this ------> 'c','c','c','c','c','c' to be saved as a string

Is this possible?

I didn't bother with CODE tags seeing as there is no real code here.

Nov 25 '08 #1
2 1093
2,851 Expert Mod 2GB
The answer is .... YES.
Expand|Select|Wrap|Line Numbers
  1. >>> listA = ['c','c','c','c','c','c']
  2. >>> ','.join(listA)
  3. 'c,c,c,c,c,c'
  4. >>> print ','.join([repr(item) for item in listA])
  5. 'c','c','c','c','c','c'
  6. >>> 
Nov 25 '08 #2
Thanks ... that's it. Perfect.
Nov 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Jean-Fran?ois Lacrampe | last post: by
7 posts views Thread by Stephan Diehl | last post: by
7 posts views Thread by Torsten Mohr | last post: by
3 posts views Thread by fdsl ysnh | last post: by
41 posts views Thread by Psykarrd | last post: by
193 posts views Thread by Michael B. | last post: by
44 posts views Thread by Christoph Zwerschke | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.