Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions library.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def add_book(filename, isbn, title, author):
# In the space below, write code that adds the key isbn
# and the value {'title':title, 'author':author}
# to the books object.

books[isbn] = {'title': title, 'author':author}
# Finally, write code that writes the new data to the library
# Do we need to return anything?
with open(filename) as f:
json.dump({'students':students,'books':books}, f)
pass
Copy link
Member

Choose a reason for hiding this comment

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

Why is this line still here?



Expand All @@ -52,8 +54,11 @@ def remove_book(filename, isbn):

# How can we *remove* an item from a dictionary?
# Write code to delete the book keyed by isbn in the space below

if 'isbn' in remove_book:
Copy link
Member

Choose a reason for hiding this comment

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

remove_book isn't defined within the scope of the function, it's the name of the function.

del remove_book['isbn']
# Now write code that saves the new version of the data to your library
with open("replayScript.json", "w") as jsonFile:
jsonFile.write(json.dumps(data))
Copy link
Member

Choose a reason for hiding this comment

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

Indentation error.

pass
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary?



Expand All @@ -62,10 +67,11 @@ def check_out(filename, isbn, s_id):

# Find a way to mark a book as checked out. Be sure to associate
# the book with the student who borrowed it!


f.__setitem__("filename",checked out)
Copy link
Member

Choose a reason for hiding this comment

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

Do you know what the magic method, setitem does?

I'm pretty confident you haven't tested this.

# And again save the data here

with open("replayScript.json", "w") as jsonFile:
jsonFile.write(json.dumps(data))
Copy link
Member

Choose a reason for hiding this comment

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

Another indentation error, and I think there's a simpler way to accomplish what you're trying to do here.

pass


Expand Down