-
Notifications
You must be signed in to change notification settings - Fork 12
My additions to library project - Bethel #2
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
base: checkout_book
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
|
|
||
|
|
@@ -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: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation error. |
||
| pass | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? |
||
|
|
||
|
|
||
|
|
@@ -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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
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?