Skip to content

Instantly share code, notes, and snippets.

@zahash
Last active January 3, 2019 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zahash/1254adfe783a1807422f1d045e5c6a49 to your computer and use it in GitHub Desktop.
Save zahash/1254adfe783a1807422f1d045e5c6a49 to your computer and use it in GitHub Desktop.
function to find the non repeating character in a string
#@time_it
def dict_method(st):
'''
This function will return the non-repeating
characters in a string
Args:
st: the input string
Return:
unique: a list of characters that don't
repeat in the string
'''
d = {}
for letter in st:
if letter not in d :
d[letter] = 1
else:
d[letter] += 1
unique = [k for k,v in d.items() if v==1]
return unique
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment