Question
I want to create a function in python that mutates two lists using only list and string built in methods. The conditions for this is
I want to create a function in python that mutates two lists using only list and string built in methods. The conditions for this is that you will be inputting two lists and two strings. def func(list1,list2,str1,str2) the goal of this function is to take everything between the specified strings in list 1 and remove it in list1 and replace it in list2 between the two specified strings. We will call these strings boundaries. An example of this function would be def func(['c','g','r','g','h','t','y'],['q','g','r','g','h','y','h','t','t','t',],'gr','ht') this would mutate list 1 removing everything in between gr and ht ['c','y'] and list 2 will have that sequence replaced with what was removed in list1 resulting in ['q','g','r','g','h','t',,'t','t',].
Another example is this would be def func(['c','h','t','g','h','g','r','t','y'],['q','h','t','g','h','y','h','g','r','t',],'gr','ht') this would mutate list 1 removing everything in between gr and ht ['c','t','y'] and list 2 will have that sequence replaced with what was removed in list1 resulting in ['q',''h','t','g','h','g','r',t',] . This example illustrates that the lists can be spliced when the string is between gr or ht or in reverse for ht or gr.
I think this could be accomplished if we make the lists into strings, check whether or not the given boundaries are in the string if they are in the first string(list1) then remove everything including the boundaries and replace it where the boundaries occur in list2.
This is what I have so far but I don't know how to go from there
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