Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) Write a function called clean that consumes alst, a list of any data type, and returns None. The function mutates alst according to the

image text in transcribed

a) Write a function called clean that consumes alst, a list of any data type, and returns None. The function mutates alst according to the following: Step 1: if a value in alst is a list data type, extract all the values in the list and add each of them to alst Step 2: remove all non-integer values from alst Step 3: ifalst contains duplicate integers, keep only one of the duplicates, remove the rest from alst For example, L -["cricket", [5,3],2, [2,7,2,8,0,9,1,10,31,True, [4,61,0,1] clean (L) mutates L such that it contains only the following values: 5,7,2,8,0,9,1,10,3,4,6.Ordering of values in L is irrelevant. Note that alst may not contain a nested list. b) Write a function called rearrange that consumes alon, a list of n natural numbers between 0 and n-1, and produces None. The function mutates alon such that each value in alon is placed at its corresponding position. For example, L1-[6, 5, 0, 3, 4, 1, 21 L2-[2, 0, 3, 4, 5, 6, 1] rearrange (L1) produces None, but mutates L1 such that L1 becomes [0, 1, 2, 3, 4, 5, 6] rearrange (L2) => None but mutates L2 such that L2 becomes [0, 1, 2, 3, 4, 5, 6] Do not use any built-in sort or reverse functions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions