Skip to content

Instantly share code, notes, and snippets.

@Bpless
Created May 16, 2014 18:46
Show Gist options
  • Save Bpless/3d3fe17430b81cd413cf to your computer and use it in GitHub Desktop.
Save Bpless/3d3fe17430b81cd413cf to your computer and use it in GitHub Desktop.
import json
from collections import OrderedDict
def sort_names():
with open("some_file.txt", "+") as f:
full_names = [line for line in f.readlines()]
result = "\n".join(full_names.sorted(full_names, key=lambda x: x.split()[-1]))
f.write(result)
def count_characters(characters):
order = OrderedDict()
for char in characters:
if char in order:
order[char] += 1
else:
order[char] = 1
final_list = []
for char, count in order.items():
if count == 1:
final_list.append(char)
return "".join(final_list)
def test_char_counter(characters="a<@guia<@de00000"):
assert count_characters(characters) == "guide"
if __name__ == "__main__":
test_char_counter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment