Remove the repeated elements of a list¶
Save all functions into the same file named remove_repeated.py.
Write the function
remove_repeated_consecutives()that given a list of integers returns another list with the same elements in the same order, but having eliminated consecutive repeated numbers. Examples:>>> remove_repeated_consecutives([3, 1, 1, 2, 2, 2, 1, 4, 5, 5, 7, 5, 5, 2, 2]) [3, 1, 2, 1, 4, 5, 7, 5, 2] >>> remove_repeated_consecutives([5, 1, 4, 2, 3]) [5, 1, 4, 2, 3] >>> remove_repeated_consecutives([]) [] >>> remove_repeated_consecutives([9, 9, 4, 6, 4, 4, 1, 1, 2]) [9, 4, 6, 4, 1, 2]
Note
More tests are provided in file
test-remove_repeat-1.txt.Write the function
remove_repeated()that given a list of integers returns another list with the same elements in the same order, but having eliminated all the repeated numbers. Example:>>> remove_repeated([3, 1, 1, 2, 2, 2, 1, 4, 5, 5, 7, 5, 5, 2, 2]) [3, 1, 2, 4, 5, 7] >>> remove_repeated([5, 1, 4, 2, 3]) [5, 1, 4, 2, 3] >>> remove_repeated([]) [] >>> remove_repeated([9, 9, 4, 6, 4, 4, 1, 1, 2]) [9, 4, 6, 1, 2]
Note
More tests are provided in file
test-remove_repeat-2.txt.
Solution
A solution of these functions is provided in the remove_repeated.py