-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrud.py
40 lines (29 loc) · 1.14 KB
/
crud.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def createNote(notes=[], note=''):
notes.append('\033[31m' + note + '\033[0m')
return 'Note added'
def readNotes(notes=[]):
if len(notes) == 0:
return 'You have no notes to display.'
return notes
def updateNote(notes=[]):
if len(notes) == 0:
return 'There are no notes to update.'
index = int(input('Enter the index of the note you want to update:'))
if index <= 0 or index > len(notes):
return 'The index does not match any notes.'
notes[index - 1] = input('Enter note update:')
return 'Updated note.'
def deleteNote(notes=[]):
index = int(input('Enter the index of the note you want to delete:'))
if index > len(notes) or index < 0:
return 'Index entered does not match any note.'
del notes[index - 1]
return 'Deleted note.'
def finalized(notes=[]):
if len(notes) == 0:
return 'No notes to finish.'
index = int(input('Enter the index of the note you want to end:'))
if index <= 0 or index > len(notes):
return 'The index does not match any notes.'
notes[index-1] = '\033[32m' + notes[index - 1] + '\033[0m'
return 'Completed note.'