python - How to get rid of duplicate entries in a comma separated string -


i have comma separated string, how remove duplicate entries in string in pythonic way.

for example string "a,a,b" should changed "a,b".

is order of elements important? if not, easiest way create set:

result = ','.join(set(text.split(','))) 

but said, won’t preserve order of original string:

>>> text = 'b,a,b' >>> ','.join(set(text.split(','))) 'a,b' 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -