Question: Only question2 Question 2: Dictionary to a tuple of lists Write a function that takes in a dictionary (described in problem 1) and converts it
Question 2: Dictionary to a tuple of lists Write a function that takes in a dictionary (described in problem 1) and converts it to a tuple of lists, where each list is the number and the corresponding age def from dict to_tuple (dict): " Converts dictionary in a list of lists > sorted (from_dict_to_tuple (people), key-1ambda tup: tup[1) ['Alexa', 3, ['Betty', 14, ['Mike, 17), ('Marina', 20, ['Robert, 23) ['Siri', 4511 >>> tutors 'name': ('Rajit', 'Joey, 'age : (21, 191) s sorted(from dict to tuple (tutors) , key-lambda tup: tup(1) II'Joey,19, ['Rajit', 21]] >from dict to tuple (empty dict) Your code is here Question 1: Modify the dictionary Write a function, add _new_ person, that takes a dictionary with two keys: "name" and "age" and a list that represent a person [name, age], then your function adds a new person to the dictionary. The dictionary must mutate (do not create another copy). def add new person (dict, 1st) """Adds new person to the dictionary >>> people ("name" "Marina", "Robert","Mke", "Siri", "Alexa", "Betty", "age": [20, 23, 17, 41, 3, 14]) >>person"Lucy",15) s>> add_new person (people, person) >>>people ('name': 'Marina', 'Robert', 'Mike', 'siri', 'Alexa', 'Betty', 'Lucy', 'age' (20, 23, 17, 41, 3, 14, 15]) # Your code is here #
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
