Question: IN PYTHON!! Let's find the longest word in the dictionary, but there's a catch. We want all words that tie the longest word in length,
IN PYTHON!!
Let's find the longest word in the dictionary, but there's a catch. We want all words that tie the longest word in length, not merely the longest word. Let's store them in a list. The dictionary text file has each line ending with a newline character ' '. As you add the words to the list, we can remove that pesky newline character by using rstrip() on the string. You can either setup a while loop and read a single line OR you can read multiple lines with readlines() (which returns a list) and iterate through that. Print out the list of candidate words. Let's also print how many words are in the dictionary afterwards.
Somewhat similar to above, let's go through the dictionary and find the word(s) that contain the most unique letters. For example between racecar and boats, racecar contains 4 (r-a-c-e) letters vs boats (b-o-a-t-s) so we would want boats over racecar. We will use the same criteria as above where we want a list of all words that tie the criteria of involving the most letters.
ake in a user word (don't worry about error checking) and see if an anagram exists in the dictionary. Little bit of a tricky detail, if a user enters a certain word in, what must you do to make sure it's actually an anagram of the entered word? Recommend using .lower() or .upper() to handle case sensitivity. Print out each and every word that is anagram of the entered word and not the entered word. If no anagrams are found, report "no anagrams were found!"
important: because each word ends with a newline character, you'll need to handle this with rstrip() or some other method
if the user enters rat, the dictionary will find 'tar ' (length of 4 characters). Since we have a bigger string, there's no way to build an anagram since the user didn't enter the newline character
For testing your function the following words do have anagrams in this dictionary:
1) restful
2) bluster
3) binary
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
