Question: 1. You need to write a simple list subclass: SpecialList class which can remove duplicates from a given list and swap two values. See
1. You need to write a simple list subclass: SpecialList class which can remove duplicates from a given list and swap two values. See below for details: Method name remove_duplicates() swap(index1, index2) Description This method returns a new list by removing the duplicates from the current SpecialList object. For example: if the given list is [1,2,4,5,6, 19, 2, 1] then the method returns [1, 2, 4, 5, 6, 19]. Hint: define an empty list and check if the number is in the empty list, if not append to the empty list. Return the empty list. Swaps the value in index1 with the vale in index2. For example: if the SpecialList object is [1, 2, 4, 5, 6], and index1 = 2 and index2 = 3, then the method should return [1, 2, 5, 4, 6]. Hint: numbers = [100, 200, 300, 400] numbers[1], numbers[2] = numbers[2], numbers[1] will result in: [100, 300, 200, 400] Object creation: Create two SpecialList objects s1 and s2 as below: s1 = SpecialList([1,2,4,5,6, 19, 2, 11) s2 = SpecialList([1,2,4,5,6]) Parameter None index1, index2 Return new list None 1. call remove_duplicates method with s1 and 2. swap the index 2 value with value in index 3 using s2 object. Print the s2 after swapping.
Step by Step Solution
There are 3 Steps involved in it
H e mainpy 1 class SpecialListlist N34500 ... View full answer
Get step-by-step solutions from verified subject matter experts
