Menu

[Solved]Python Step Word Formed Taking Given Word Adding Letter Anagramming Result Example Startin Q37132952

In Python:

A step word is formed by taking a given word, adding a letter,and anagramming the result. For example, starting with the word”APPLE”, you can add an “A” and anagram to get “APPEAL”.

Given a global dictionary of words, create a function step(word)that returns a list of all unique, valid step words appearing inthe dictionary.

The dictionary of words to use may be found on/usr/share/dict/words on Unix machines or downloaded fromhttps://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt

Create a dictionary of words stored as a python list using thestring split() function as follows:

>>> words = open(‘words.txt’,encoding=’ascii’).read().upper().split()
>>> len(words)
235886

>>> step(“APPLE”)
[‘APPEAL’, ‘CAPPLE’, ‘PALPED’, ‘LAPPED’, ‘DAPPLE’, ‘ALEPPO’,’LAPPER’, ‘RAPPEL’, ‘LAPPET’, ‘PAPULE’, ‘UPLEAP’]

Expert Answer


Answer to In Python: A step word is formed by taking a given word, adding a letter, and anagramming the result. For example, start… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *