Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python intvert problem Write a pure function intvert (1st) that takes in a list of variable length and returns a new list containing every integer
python intvert problem
Write a pure function intvert (1st) that takes in a list of variable length and returns a new list containing every integer in the original list, but in reverse order. (So [1,2,3] becomes [3,2,1] )All other datatypes should be removed. If the list contains no integers, you should return an empty list. Some example interactions are shown below: >>> intvert ([1,2,3]) >>> intvert([5, "pineapple", 50.5, 1]) 1, 51 >>>intvert ([0.0, 1.3, "9"1) [ 1 It may help to use the type ) function to check the datatype of each item in the input list. Constraints/Comments The function should return a new list, rather than mutate the original list. You may assume that the user will enter a list, but you cannot assume that the list will be of a particular length, or contain any items at all You cannot assume the datatype of the elements of the input list. Test your program with strings, floats, nested lists, etc. Your return list must only contain the ints in the original list, no other types You must invert the given list manually, you cannot use the built-in.reverse) for this problem. Clarification (2/19): You may not use slice to reverse the list in a singleStep 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