Created
May 16, 2014 18:46
-
-
Save Bpless/3d3fe17430b81cd413cf to your computer and use it in GitHub Desktop.
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
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