471,592 Members | 1,159 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,592 software developers and data experts.

Some help with strings

Hi,

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.

Thanks
Nov 25 '08 #1
2 1117
bvdet
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
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.