Some help with strings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fordie1000
    New Member
    • Mar 2008
    • 32

    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
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    The answer is .... YES.
    [code=Python]>>> listA = ['c','c','c','c' ,'c','c']
    >>> ','.join(listA)
    'c,c,c,c,c,c'
    >>> print ','.join([repr(item) for item in listA])
    'c','c','c','c' ,'c','c'
    >>> [/code]

    Comment

    • fordie1000
      New Member
      • Mar 2008
      • 32

      #3
      Thanks ... that's it. Perfect.

      Comment

      Working...