Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem #2: Create a function that sorts values into separate buckets in a dictionary based on their types. #This is the function that will decide
Problem \#2: Create a function that sorts values into separate "buckets" in a dictionary based on their types. \#This is the function that will decide which bucket the item goes in \#use if else statements and the type() function to check the type of \#the item and add it to the appropriate list in the dictionary. def add_to_bucket(dictionary, item): \# Fill in the body here \# Here we define our dictionaries buckets = \{ "strings" : [], "integers" : [], "floats" : [] \} Here we have our function calls \# Hd_to_bucket(buckets, "hello") addto_bucket(buckets, 13) addto_bucket(buckets, "world") add_to_bucket(buckets, "foo bar baz") add_to_bucket(buckets, 12) add_to_bucket(buckets, 2.13) add_to_bucket(buckets, 3.23) print(buckets) File "", line 8 buckets = \{ IndentationError: expected an indented block assert buckets ==\{'strings': ['hello', 'world', 'foo bar baz'], 'floats': [2.13, 3.23], 'integers': [13, 12] \} print("Test case passed")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started