Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Python - Convert word to list

  1. #11
    Join Date
    Sep 2005
    Location
    The American Empire
    Beans
    340

    Re: Python - Convert word to list

    Thanks for the links pmasiar.
    Registered Linux User # 437006
    http://sidux.com/ - K Desktop Environment (Debian Sid)
    MasterShaper - Network traffic under control

    Currently listening to

  2. #12
    Join Date
    May 2005
    Location
    Lecce, Italy
    Beans
    6,168
    Distro
    Ubuntu

    Re: Python - Convert word to list

    Quote Originally Posted by <mawe> View Post
    Hi!

    Code:
    >>> txt = "hello"
    >>> txt_list = list(txt)
    >>> txt_list
    ['h', 'e', 'l', 'l', 'o']
    Regards, mawe
    OR, if you have time to waste (2 seconds? ) and you don't want to use "list" (if you like "for" better) you can try with:
    Code:
    txtTest = 'Hello'
    txtList = []
    
    for i in txtTest:
        txtList.append(i)
    
    print txtList

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •