Thread: String

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11

    String


    Hi All

    I have a file with something like this essrgyhvc I want to split the chars as follow
    'e','s','s','r','g','y','h','v','c' is there a way

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    37
    Rep Power
    10
    here's one quick and easy way:
    >>> new = []
    >>> s = 'essrgyhvc'
    >>> for ltr in s:
    ... new.append(ltr)

    >>>new
    ['e','s','s','r','g','y','h','v','c']
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    I agree
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    52
    Hi!

    Here's a quicker and easier way
    Code:
    >>> s = "essrgyhvc"
    >>> l = list(s)
    >>> l
    ['e','s','s','r','g','y','h','v','c']
    Regards, mawe

    Comments on this post

    • Zone agrees : oh yeah, I forgot about list()! you're right!
    • CyBerHigh agrees

IMN logo majestic logo threadwatch logo seochat tools logo