In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of November 23rd
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #06 exercise sheet]
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
Principal Seymour Skinner is going through a daunting pile of student reports in his office at Springfield Elementary. It’s the end of the semester, and he’s supposed to review each student’s work before final grades go out. But as he flips through the stack, he starts to notice something strange - several students seem to have accidentally (or lazily) submitted duplicate copies of their reports. Bart, of course, is the worst offender, having submitted the same science project on “How to Catch a Frog” no less than five times.
Skinner sighs, knowing he doesn't have time to read all these variations. What he really wants to see are the reports that students only submitted once - the ones he can trust as the student's intended final submission. Can you help him keep only the unique reports?
Write a function unique(lst) that given a list lst returns a new list containing only the unique elements, that is, those that appear only once in lst.
The following limits are guaranteed in all the test cases that will be given to your program:
0 ≤ |lst| ≤ 100 | Number of elements in list |
Example Function Calls | Example Output |
print(unique(["bart","lewis","bart", "martin", "bart", "nelson","martin"])) print(unique(['a','b','c','d'])) print(unique([True, False, True, False])) print(unique(['f', 'o', 'r', 't', 'y', 't', 'w', 'o'])) |
['lewis', 'nelson'] ['a', 'b', 'c', 'd'] [] ['f', 'r', 'y', 'w'] |