Question: please use python and for loop to create function J. Ullstraling tupie values by type Ms. Frizzle has a list of tuples, one tuple for
J. Ullstraling tupie values by type Ms. Frizzle has a list of tuples, one tuple for each student in her class. Each tuple contains the name of a student (type str), the perm number of type int) of that student, and a boolean value to indicate whether the student was present that day (type boot). Unfortunately, each tuple gotjumbled such that the name, perm number, and attendance status are not necessarily in that order. For example, one tuple is (True, 65473, Sarah'), and Ms. Frizzle would like it to read ''Sarah, 65473, True) Help Ms. Frizzle write a function unscrambleTuples() that takes in a parameter list_of_tuples and returns a list of lists that stores the values in the way Ms.Frizzle wants: student's name, student IDattendance flag (Istr, int, bool). For example, for a list that contains a single tuple, unscranbleTuples1012345, False, 'Frodo ) should return It Frodo', 12345, Falsell. Another example: unscrambleTuples([('Sarah', 65473, True). (True, 1234, 'Beyonce'), (False, 'Molly',2344) 1) should return It'Sarah', 65473, Truel, Beyonce', 1234, Truel. I'Molly'. 2344, Falsell. As usual, think how you would approach the solution and draft a pseudocode for your approach (add it as comments in your fiel: # Create # For each ... TODO Return the list IMPORTANT: When you create an empty list, you cannot directly index it, because it contains no elements. If you use append(), it adds elements to the end of the list, which might not be the order that you want. Sometimes, instead of an empty list, you can create a list with the paceholder ("stub") values, which then gives you the ability to index (and change) those values directly def unscrambleTuples (list of tuples): Given a list of tuples that contain values of type string, int, and bool, unscramble the values to create a new list that turns each tuple from the List_of_tuples into a list with the values arranged by type as follows: Istr, int, booll. return "stub funtion is behaving as expected
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
