Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a word list
#1
I would like to take any text document and make a word list from the file with no duplicates. I don't know much about programming. This is the best I have been able to come up with. Thanks!

 	
def MakeWordList():
    with open('test.txt','r') as f:
        data = f.read()
    return set([word for word in data.split()])

    print ()
Reply


Messages In This Thread
Creating a word list - by opencircles - Mar-19-2019, 04:54 PM
RE: Creating a word list - by snippsat - Mar-19-2019, 05:18 PM
RE: Creating a word list - by MohanReddy - Mar-19-2019, 06:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  For Word, Count in List (Counts.Items()) new_coder_231013 6 3,001 Jul-21-2022, 02:51 PM
Last Post: new_coder_231013
  find some word in text list file and a bit change to them RolanRoll 3 1,671 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Class-Aggregation and creating a list/dictionary IoannisDem 1 2,059 Oct-03-2021, 05:16 PM
Last Post: Yoriz
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,663 Aug-12-2021, 04:25 PM
Last Post: palladium
  Trying to get the first letter of every word in a list DanielCook 2 2,263 Jan-05-2021, 05:06 PM
Last Post: deanhystad
  Creating list of lists from generator object t4keheart 1 2,299 Nov-13-2020, 04:59 AM
Last Post: perfringo
  Creating a dictionary from a list Inkanus 5 3,336 Nov-06-2020, 06:11 PM
Last Post: DeaD_EyE
  Creating a list of dictionaries while iterating pythonnewbie138 6 3,464 Sep-27-2020, 08:23 PM
Last Post: pythonnewbie138
  Trying to find first 2 letter word in a list of words Oldman45 7 3,977 Aug-11-2020, 08:59 AM
Last Post: Oldman45
  Creating a list of RSSI value and send it to the server. Azuan 0 2,739 Jun-08-2020, 11:22 PM
Last Post: Azuan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020