abbas-booklib 0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
mylibrary/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mylibrary/library.py,sha256=EoiELI7K2woSOJVtSJAQYNq_RUq1_KsBziIgem2JTt0,1301
|
|
3
|
+
abbas_booklib-0.1.dist-info/METADATA,sha256=9_GWgBfj4pg7EEAoPPOIpkGcitUT7WbNsqfquSJMorE,58
|
|
4
|
+
abbas_booklib-0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
abbas_booklib-0.1.dist-info/top_level.txt,sha256=qmgk4BZwTMCBa1l_FQ9vfMcdQIvZTFPAkbgZz786anU,10
|
|
6
|
+
abbas_booklib-0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mylibrary
|
mylibrary/__init__.py
ADDED
|
File without changes
|
mylibrary/library.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# we can also write:
|
|
2
|
+
#class Library:
|
|
3
|
+
# def __init__(self, books):
|
|
4
|
+
# self.books = books
|
|
5
|
+
#library1 = Library('1984')
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Library:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.books = []
|
|
11
|
+
|
|
12
|
+
def add_book(self, title, author):
|
|
13
|
+
self.books.append({
|
|
14
|
+
'title' : title ,
|
|
15
|
+
'author' : author
|
|
16
|
+
})
|
|
17
|
+
def show_book(self,):
|
|
18
|
+
for book in self.books:
|
|
19
|
+
print(f" title : {book['title']}| author : {book['author']}")
|
|
20
|
+
|
|
21
|
+
def remove_book(self, title):
|
|
22
|
+
for book in self.books:
|
|
23
|
+
if book['title'] == title:
|
|
24
|
+
self.books.remove(book)
|
|
25
|
+
print(f"the book {title} was removed successfully")
|
|
26
|
+
break
|
|
27
|
+
else:
|
|
28
|
+
print(f"the book {title} was not found")
|
|
29
|
+
|
|
30
|
+
def search_book(self, title):
|
|
31
|
+
for book in self.books:
|
|
32
|
+
if book['title'] == title:
|
|
33
|
+
print(f"the book {title} was found")
|
|
34
|
+
break
|
|
35
|
+
else:
|
|
36
|
+
print(f"the book {title} was not found")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
library = Library()
|
|
40
|
+
print(library.books)
|
|
41
|
+
library.add_book("1984", "George Orwell")
|
|
42
|
+
library.add_book("The Hobbit", "J.R.R. Tolkien")
|
|
43
|
+
print(library.books)
|
|
44
|
+
library.remove_book('22')
|
|
45
|
+
library.search_book('1984')
|
|
46
|
+
print(library.books)
|