Python Forum
Extracting random word from list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extracting random word from list
#11
Assuming you are copying that to your program and not writing it out, as well as {} separating your "sets", and | separating your words you could just do
text = '''
{{howdy|hey|hey there|heyyy|hi cutey|hi there =)|sup|heyy|hey hey|heyyy|hiya|heya|heyyyy|hello there|hey babes|hey sexy|hey heyy|hi there}{..|.|,|...} {thanks|thnx|thank you|ty} {4|for} the {follow|add}{...|.|..} {whats up|what's up|what is up|what you up to|what u up to|what ya up to|how ya doing|how you dhow ya doin|how you doin|whats going on|what is going on|what's going on|what is goin on|whats goin on|what's goin on|how are ya|how are you|how are u}{?|??|???} {nm|not much|chilling|chillin|relaxing|relaxin|hanging out|hangin out|chillin out|chilling out|lounging out|coolin out} {here|over here}{.|,} {txt me|t xt me|tx t me|t.xt me|tx.t me|t.x.t me|text me|t ext me|te xt me|tex t me|t.ext me|te.xt me|tex.t me}{...|} {i am|im|i'm} {downright|flat out|terribly|extremely|really|super|absolutely|truly} bored{.|..|...} %s {..|....|..}
'''
for element in text.split('}'):
    print(element.split('|'))
Output:
['\n{{howdy', 'hey', 'hey there', 'heyyy', 'hi cutey', 'hi there =)', 'sup', 'heyy', 'hey hey', 'heyyy', 'hiya', 'heya', 'heyyyy', 'hello there', 'hey babes', 'hey sexy', 'hey heyy', 'hi there'] ['{..', '.', ',', '...'] [' {thanks', 'thnx', 'thank you', 'ty'] [' {4', 'for'] [' the {follow', 'add'] ['{...', '.', '..'] [' {whats up', "what's up", 'what is up', 'what you up to', 'what u up to', 'what ya up to', 'how ya doing', 'how you dhow ya doin', 'how you doin', 'whats going on', 'what is going on', "what's going on", 'what is goin on', 'whats goin on', "what's goin on", 'how are ya', 'how are you', 'how are u'] ['{?', '??', '???'] [' {nm', 'not much', 'chilling', 'chillin', 'relaxing', 'relaxin', 'hanging out', 'hangin out', 'chillin out', 'chilling out', 'lounging out', 'coolin out'] [' {here', 'over here'] ['{.', ','] [' {txt me', 't xt me', 'tx t me', 't.xt me', 'tx.t me', 't.x.t me', 'text me', 't ext me', 'te xt me', 'tex t me', 't.ext me', 'te.xt me', 'tex.t me'] ['{...', ''] [' {i am', 'im', "i'm"] [' {downright', 'flat out', 'terribly', 'extremely', 'really', 'super', 'absolutely', 'truly'] [' bored{.', '..', '...'] [' %s {..', '....', '..'] ['\n']
and yes it would need a little customizing
Recommended Tutorials:
Reply


Messages In This Thread
Extracting random word from list - by zykbee - Nov-06-2017, 10:08 PM
RE: Extracting random word from list - by metulburr - Nov-06-2017, 10:55 PM
RE: Extracting random word from list - by zykbee - Nov-06-2017, 10:56 PM
RE: Extracting random word from list - by metulburr - Nov-06-2017, 11:01 PM
RE: Extracting random word from list - by zykbee - Nov-06-2017, 11:03 PM
RE: Extracting random word from list - by metulburr - Nov-06-2017, 11:05 PM
RE: Extracting random word from list - by metulburr - Nov-06-2017, 11:06 PM
RE: Extracting random word from list - by zykbee - Nov-06-2017, 11:10 PM
RE: Extracting random word from list - by metulburr - Nov-06-2017, 11:14 PM
RE: Extracting random word from list - by zykbee - Nov-06-2017, 11:16 PM
RE: Extracting random word from list - by metulburr - Nov-06-2017, 11:31 PM
RE: Extracting random word from list - by zykbee - Nov-06-2017, 11:35 PM
RE: Extracting random word from list - by metulburr - Nov-06-2017, 11:40 PM
RE: Extracting random word from list - by zykbee - Nov-06-2017, 11:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sample random, unique string pairs from a list without repetitions walterwhite 1 488 Nov-19-2023, 10:07 PM
Last Post: deanhystad
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,300 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  List of random numbers astral_travel 17 2,781 Dec-02-2022, 10:37 PM
Last Post: deanhystad
  [split] why can't i create a list of numbers (ints) with random.randrange() astral_travel 7 1,574 Oct-23-2022, 11:13 PM
Last Post: Pedroski55
  For Word, Count in List (Counts.Items()) new_coder_231013 6 2,674 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,571 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,553 Aug-12-2021, 04:25 PM
Last Post: palladium
  Extracting Elements From A Website List knight2000 2 2,331 Jul-20-2021, 10:38 AM
Last Post: knight2000
  Unable to use random.choice(list) in async method spacedog 4 3,494 Apr-29-2021, 04:08 PM
Last Post: spacedog
Thumbs Down extracting data/strings from Word doc mikkelibsen 1 1,958 Feb-10-2021, 11:06 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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