Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my first pull request #9

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion examples/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def keyfunc2(word):
# s = "food"
# dir(s)
#
# This will dump a list of all the things you can call the variable with.
# This will dump a list of all the things you can c all the variable with.
# E.g. "join" will be in that list if you called dir() on a string.
# This means that you call `s.join()`.
#
Expand Down
1 change: 1 addition & 0 deletions exercises-hello/hello.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
#
# TODO: write your code below

print "hello world"
2 changes: 2 additions & 0 deletions exercises-hello/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python
print "this is a python script!"
12 changes: 8 additions & 4 deletions exercises-spellchecker/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@ def load(dictionary_name):
Each line in the file contains exactly one word.
"""
# TODO: remove the pass line and write your own code
pass
s = set()
words = open(dictionary_name, "rb")
for word in words:
s.add(word.strip())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also use set comprehensions:

return {word.strip() for word in open(dictionary_name, "rb")}

return s

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 = ()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also dictionary.clear()