Skip to content

Commit 4957f27

Browse files
committed
Add DocStrings and update Readme > grocery-shopping
1 parent 44f362f commit 4957f27

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

grocery-shopping/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Grocery shopping
22

3-
Store grocery items in a `.data` file
3+
Stores grocery items in a `.data` file
44

55
### Worked concepts
66
* File reading and writing
77
* Pickle
8-
* Lists
8+
* Lists
9+
* Doc strings

grocery-shopping/grocery_list_repository.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66

77
def persist(items):
8+
'''stores a list in a file'''
89
with open(file, "wb") as f:
910
pickle.dump(items, f)
1011

1112

1213
def read():
14+
'''get all items and returns a list'''
1315
items = []
1416
if file.is_file():
1517
with open(file, "rb") as f:
@@ -18,6 +20,7 @@ def read():
1820

1921

2022
def delete(item):
23+
'''deletes a item from the list and updates de file'''
2124
items = read()
2225
items.remove(item)
2326
with open(file, "r+b") as f:

grocery-shopping/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def main():
4040
print("0 - Exit")
4141
option = options(int(input("> ")))
4242
if option == 1:
43+
print('Exiting program')
4344
break
4445

4546

0 commit comments

Comments
 (0)