Question: Please Complete the below code in Python Given a list of words from an English dictionary and a word, return a set of words in
Please Complete the below code in Python
Given a list of words from an English dictionary and a word, return a set of words in the dictionary that are anagrams of the word. An anagram of a word is formed by rearranging the letters of the word. For example, east is an anagram of seat.
def anagrams(dictionary,word):
Test Case:
import unittest from solution import anagrams class Test(unittest.TestCase): def test_simple_checks_pots(self): self.assertEqual(anagrams(["post","pots","spot","stop","tops"],"pots"), ["post","pots","spot","stop","tops"]) def test_simple_checks_pears_with_a_larger_dictionary(self): self.assertEqual(anagrams(["parse","pears","reaps","spare","spear","least","slate","stale","steal","post","pots","spot","stop","tops","skate","stake","steak","takes"],"pears"), ["parse","pears","reaps","spare","spear"])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
