Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 382 Bytes

remove-duplicate-characters.md

File metadata and controls

15 lines (13 loc) · 382 Bytes
title description author tags
Remove Duplicate Characters
Removes duplicate characters from a string while maintaining the order.
axorax
string,duplicates,remove
def remove_duplicate_chars(s):
    seen = set()
    return ''.join(char for char in s if not (char in seen or seen.add(char)))

# Usage:
remove_duplicate_chars('programming') # Returns: 'progamin'