Results 1 to 2 of 2

Thread: Need some python help

  1. #1
    Join Date
    Nov 2011
    Posts
    160
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need some python help

    Well I'm importing a txt file,

    k = open('k.txt', encoding = latin1)
    And then transform it to a list.
    However, some words like wai wai (that are in the same line in the txt file) becomes seperated, so for example it becomes ['wai', 'wai'], but i want them in the same listspot, ['wai wai', .....]

    How do i do that?

    Thanks

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    How did you transform it to a list?
    Code:
    mylist = []
    
    with open('C:/k.txt') as f:
        for line in f:
            mylist.append(line)
    
    print mylist
    This should work.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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