example
unknown
python
3 years ago
650 B
8
Indexable
import random words = ['colossal', 'sheet', 'fill', 'modern', 'sulky', 'appear', 'dependent', 'argue', 'potato', 'eatable', 'talk', 'coat'] # generate random sentences from above words total = [] for x in range(10): sentence = [random.choice(words) for x in range(random.randrange(5, 8))] sentence = ' '.join(sentence).capitalize() total.append(sentence) total_str = '. '.join(total) print(total_str) # extract unique words unique = [item.strip('.').lower() for item in total_str.split()] unique = sorted(set(unique)) unique_str = ', '.join(unique) print('---'*10) print('unique words: {}'.format(unique_str))
Editor is loading...