Re: split

Discussion in 'Python' started by Gandalf, Jun 11, 2004.

  1. Gandalf

    Gandalf Guest

    This way:

    >>> s = 'some string'
    >>> l = []
    >>> for c in s:

    .... l.append(c)
    ....
    >>> l

    ['s', 'o', 'm', 'e', ' ', 's', 't', 'r', 'i', 'n', 'g']
    >>>


    However, in most cases, you do not need this. Please note that strings
    are seuqences. You can do these:

    s[2]
    s[1:3]
    s[-4]

    e.g. almost anything that you could do with a list.

    Best,

    G

    km wrote:

    > hi all,
    >i have a string like this
    >s = "znfciuheiahkcjnksdhuicvh"
    >how to cut it into individual characrers and create an array out of it ?
    >i tried s.split()
    >but it doesnt work
    >regards,
    >KM
    >
    >
    >
    >
    >
     
    Gandalf, Jun 11, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    470
  2. Carlos Ribeiro
    Replies:
    11
    Views:
    702
    Alex Martelli
    Sep 17, 2004
  3. trans.  (T. Onoma)

    split on '' (and another for split -1)

    trans. (T. Onoma), Dec 27, 2004, in forum: Ruby
    Replies:
    10
    Views:
    218
    Florian Gross
    Dec 28, 2004
  4. Sam Kong
    Replies:
    5
    Views:
    246
    Rick DeNatale
    Aug 12, 2006
  5. Stanley Xu
    Replies:
    2
    Views:
    618
    Stanley Xu
    Mar 23, 2011
Loading...

Share This Page