Question
Write a function that takes as input a list that contains nested lists of two (2) elements each. For each nested list (call them pairs),
Write a function that takes as input a list that contains nested lists of two (2) elements each. For each nested list (call them pairs), swap the value of the pairs. This function should be a mutating function that modifies the original list passed in. Specification:
Name: flip_lists
Parameters: a list
Returns: the mutated list (yes, this function both mutates the list _and_ returns the mutated list)
Side Effects this function mutates the list passed in and swaps the values of each pair (nested list) within the list passed in
Example: Given an input: [['hello', 'world'], [1, 2]], the side effect of this function will mutate the original list passed in, resulting in its value being [['world', 'hello'], [2, 1]]
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