Browse Source

changed (internal) _remove_note() method to (not internal) method remove_note()

master
T. Meissner 10 years ago
parent
commit
14772e3f2d
2 changed files with 3 additions and 6 deletions
  1. +1
    -1
      python_3_oop/chapter02/menu.py
  2. +2
    -5
      python_3_oop/chapter02/notebook.py

+ 1
- 1
python_3_oop/chapter02/menu.py View File

@ -92,7 +92,7 @@ Notebook Menu
def remove_note(self):
'''Remove note with given id from note list'''
id = input("Enter a note id: ")
if self.notebook._remove_note(id):
if self.notebook.remove_note(id):
print("Note with id {0} removed.".format(id))
else:
print("Note with id {0} doesn't exist.".format(id))


+ 2
- 5
python_3_oop/chapter02/notebook.py View File

@ -65,16 +65,13 @@ class Notebook:
return note
return None
def _remove_note(self, id):
def remove_note(self, id):
'''Remove note(s) with given id from note list'''
if self._find_note(id):
removed = []
index = 0
for note in self.notes:
for index, note in enumerate(self.notes):
if str(note.id) == str(id):
removed.append(self.notes.pop(index))
else:
index += 1
self._set_id()
return removed
return False


Loading…
Cancel
Save