diff --git a/exercises-spellchecker/dictionary.py b/exercises-spellchecker/dictionary.py index e71878a..9a2995d 100644 --- a/exercises-spellchecker/dictionary.py +++ b/exercises-spellchecker/dictionary.py @@ -4,7 +4,6 @@ with a python dictionary here--anytime you see the word "dictionary", we mean English dictionary). """ - def load(dictionary_name): """ Opens the file called `dictionary_name` and returns @@ -15,23 +14,29 @@ def load(dictionary_name): Each line in the file contains exactly one word. """ - # TODO: remove the pass line and write your own code - pass + f = open(dictionary_name) + lines = f.readlines() + words = set() + for x in lines: + stripped = x.strip + words.add(stripped) + f.close() + return words def check(dictionary, word): """ Returns True if `word` is in the English `dictionary`. """ - pass + return word in dictionary def size(dictionary): """ Returns the number of words in the English `dictionary`. """ - pass + return len(dictionary) def unload(dictionary): """ Removes everything from the English `dictionary`. """ - pass + dictionary.clear diff --git a/hello.py b/hello.py new file mode 100644 index 0000000..8cde782 --- /dev/null +++ b/hello.py @@ -0,0 +1 @@ +print("hello world") diff --git a/script.py b/script.py new file mode 100644 index 0000000..6a36816 --- /dev/null +++ b/script.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python +print ("this is a python script!")