Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In North America, there is a very famous game called Bananagrams, based all around the concept of an Anagram. Anagrams are words that have all

image text in transcribed
In North America, there is a very famous game called Bananagrams, based all around the concept of an Anagram. Anagrams are words that have all the same characters as another word, but in a different order. For example, tac , cat , and act are all anagrams of each other. undertale and deltarune are also anagrams, incidentally. In this question you will take a sentence, and group together all words within that sentence which are anagrams of one another. Write a function called bananagrams(s) that takes in a string s , and returns a list of sets of strings. Each set will contain at least one word from the input sentence. All of the words in each set must be anagrams of each other. Each word in the input sentence must be put in exactly one set. If two words in the input sentence are anagrams, they must be in the same set. You can assume the string has been cleaned for you before being passed to the function. It will contain no punctuation, no uppercase letters, no numbers, etc... Only lowercase letters and the space character. If the string is empty, you should return a list with a set in it, and that set contains the empty string. HINT: You need to split the string by the space character to get a list of words. EXTRA HINT: A dictionary could be really helpful here. In [ ] : # YOUR CODE HERE raise Not ImplementedError ( ) In [ ]: print (f"Question 3 - Test 1 Passed:". bananagrams("and dan loleh said hello to his mother ot loleh" ) == [ ['and' , 'dan'}, {'loleh' , 'hello's. {'said'), {'to'. 'ot'}, {'his'). { ' mother '} In [ ]: # Hidden Test for Question 3 In [ ]: # Hidden Test for Question 3 In [ ]: # Hidden Test for Question 3 In [ ]: # Hidden Test for Question 3 In [ ]: # Hidden Test for Question 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

1 The definition and functions of money

Answered: 1 week ago