Last active
December 9, 2018 11:27
-
-
Save abdulateef/516dbd27c10984f7f1b3e42679b7008d to your computer and use it in GitHub Desktop.
Write a function which will take one string argument containing characters between a-z, and should remove all repeated characters (dupliactaes) in the string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_duplicates(string): | |
unique = ''.join(sorted(set(string))) | |
removed = len(string) - len(unique) | |
return unique, removed | |
print(remove_duplicates('accccount')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment