Question: Since it needs a word_compare code here is mine currently. . A python program can be run all by itself, or it may be used
Since it needs a word_compare code here is mine currently.
. A python program can be run all by itself, or it may be used by other programs. The word_compare.py program is not really meant to be run on its own; it is meant to be imported for use by other programs. Write a python program called FindAnagrams.py that: imports the function word_compare defines a function find_anagrams that: uses word_compare to scan each word in a set against every other word returns a string representing all anagrams in the list, as below For instance, if your words were: words = ["tar", "rat", "art", "face", "cafe", "hello"] Then your function should return the following string : tar: ['rat', 'art'] rat: ['tar', 'art'] art: ['tar', 'rat'] face: ['cafe'] cafe: ['face'] hello: [] Note that find_anagrams should return a string, not print it. 1 "def word_compare(a, b="steal"): 2 3 - if type(a) == int or type (b) == int: 4 return "Those aren't strings!" 5 elif sorted (a) sorted(b): 6 return "Anagram" 7 else: 8 tup = (a,b) 9 return tup 10 11 word_compare("rat") 12 word_compare("hello, goodbye") 13 word_compare (22) Ha min 000 ==
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
