Thursday, May 22, 2014

SOLUTION Exercise 13: List Duplicates

Exercise

Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates.
Extras:
  • Write two different functions to do this - one using a loop and constructing a list, and another using sets.
  • Go back and do Exercise 5 using sets, and write the solution for that in a different function.

Sample solution

This solution has two different functions doing the solution in two ways - one does it with a loop, and one with sets!

No comments:

Post a Comment