Question: (Duplicate word removal) Write a function that reads in a text and determines the number of unique words in alphabetical order. Read in a text,
(Duplicate word removal) Write a function that reads in a text and determines the number of unique words in alphabetical order.
- Read in a text, for example Let it be let it be, use string.split(separator) function to break it into a list of strings/words by the specified separator (white space).
- Displays in alphabetical order only the unique words. Treat uppercase and lowercase letters the same (as lowercase).
- Demonstrate how to use string.split(separator) ( If separator not provided, then any white space is a separator).
text = Let it be let it be
myList = text.split( ) # myList is a list: [Let, it, be, let, it, be]
- The function should use a set to get the unique words in the list.
- Print out the unique words and the number of unique words
- Test your function with other text/sentences
python please.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
