Created
October 4, 2018 04:18
-
-
Save shreezan123/c606f5038ee9e379cf22963ccc1dc9c2 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
class Library: | |
d1 = {} | |
def __init__(self): | |
pass | |
def add_book(self,book): | |
self.d1[book] = True | |
def check_out_book(self,book): | |
if book in self.d1: | |
del(self.d1[book]) | |
def return_book(self,book): | |
self.d1[book] = True | |
def has_book(self,book): | |
if book in self.d1: | |
return True | |
return False | |
l = Library() | |
l.add_book("physics") | |
l.add_book("math") | |
print l.has_book("physics") #Expected true | |
print l.has_book("math") #Expected true | |
l.check_out_book("math") | |
print l.has_book("math") #Expected false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment