List of all unique characters in a string?

后端 未结 7 1574
再見小時候
再見小時候 2020-11-27 18:03

I want to append characters to a string, but want to make sure all the letters in the final list are unique.

Example: \"aaabcabccd\"

7条回答
  •  天命终不由人
    2020-11-27 18:21

    if the result does not need to be order-preserving, then you can simply use a set

    >>> ''.join(set( "aaabcabccd"))
    'acbd'
    >>>
    

提交回复
热议问题