Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help with this Python 3 function: I can't seem to get this function to work properly and I can't find any solutions as to how
Help with this Python 3 function:
I can't seem to get this function to work properly and I can't find any solutions as to how to figure it out. Any help is appreciated!
extract negatives: The first argument, xs, contains integers. We will be removing any negative integers we find in xs, and appending them to the second argument, new home. A reference to the list that received negatives must be returned. When no second argument is given, a list of all the extracted negatives should be created and returned. o Figuring out the signature of this function is part of the task. Careful: What default value do you want to use for new home? What happens when we call the function multiple times in the same coding session? (try it out) o Go ahead and use methods like .insert .pop .append() o You might need to iterate and update the list at the same time. Hint: if you need to traverse a list from front to back, but you don't always want to go to the next index location, while loops can be very useful we get to control when (which iteration) to step forward. Examples: o XS [1 22,3, -44, -5, 6,7] extract negatives (xs) [-22, 44 -51 #return a list of negatives XS [1, 3, 6, 7] fremove negatives from xs o xs [1 22,3, -44, -5,6,71 negatives [-3, -11 extract negatives (xs, negatives) -3, -1, 22, -44, -51 negatives [-3, -1, 22, -44, -51 #new negatives appended to the list XS [1, 3, 6, 7]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