How do I print my list of numbers in python without "set" before it? With a function where it returns a new list & the numbers only occur once -
i have defined function takes list of numbers , returns new list each element of first list occurs once.
def unique(a): homecoming set(a) print unique([1,2,3,4,1,5])
i tried print ",".join(str(e) e in s)
doesn't work because have print new list there no repeated numbers.
you can use:
list(set(a))
this convert list set, maintain unique occurrences, convert list.
example:
>>> list(set([1, 1, 2, 2, 3, 3])) [1, 2, 3]
python list numbers set
No comments:
Post a Comment