python - Extract the list of unique numbers out of a string of numbers -
def unique(a): in a: set(a) set([1,2,3])
print unique([1,1,2,3,2])
define function unique(a) takes list of numbers , returns new list each element of occurs once. new list should have elements in same order appear in a. function must utilize set.
set want :
>>> a=[1,1,2,2,3,3] >>> set(a) set([1, 2, 3]) python string list
No comments:
Post a Comment