Please help if possible..the yellow section is the prompt.. This is a duplicate
ID: 3857638 • Letter: P
Question
Please help if possible..the yellow section is the prompt..
This is a duplicate of the docstring: Given some strings (in any set or sequence type), filter out any non-alphabetic characters from each string, leaving only the alphabetic characters in each. Collect these simplified strings, and return a frozenset of them. HINT: You can create a frozenset, from a list, tuple, or set, using the frozenset constructor: fs frozenset ( list-of-strings) = https://docs.python.org/3/library/stdtypes.html ?highlight-frozenset#frozenset The input dataset might have duplicates; since you are returning a frozenset, duplicates will be eliminated. Likewise, if two strings start out different but are identical after filtering (such as "it's" and "its"), only one will be returned. If a string filters down into the empty string, do *NOT include it in the set to be returned.Explanation / Answer
The answer is as follows:
def alpha_only_words(words):
list = []
for i in range(len(words)):
new = ""
word = words[i]
for c in word:
if c.isalpha():
new = new + c
if len(new) > 0:
list.append(new)
fs = frozenset(list)
return fs
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.