File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 1
1
# Grocery shopping
2
2
3
- Store grocery items in a ` .data ` file
3
+ Stores grocery items in a ` .data ` file
4
4
5
5
### Worked concepts
6
6
* File reading and writing
7
7
* Pickle
8
- * Lists
8
+ * Lists
9
+ * Doc strings
Original file line number Diff line number Diff line change 5
5
6
6
7
7
def persist (items ):
8
+ '''stores a list in a file'''
8
9
with open (file , "wb" ) as f :
9
10
pickle .dump (items , f )
10
11
11
12
12
13
def read ():
14
+ '''get all items and returns a list'''
13
15
items = []
14
16
if file .is_file ():
15
17
with open (file , "rb" ) as f :
@@ -18,6 +20,7 @@ def read():
18
20
19
21
20
22
def delete (item ):
23
+ '''deletes a item from the list and updates de file'''
21
24
items = read ()
22
25
items .remove (item )
23
26
with open (file , "r+b" ) as f :
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ def main():
40
40
print ("0 - Exit" )
41
41
option = options (int (input ("> " )))
42
42
if option == 1 :
43
+ print ('Exiting program' )
43
44
break
44
45
45
46
You can’t perform that action at this time.
0 commit comments