diff --git a/python_3_oop/chapter02/menu.py b/python_3_oop/chapter02/menu.py index 60665ff..7245f01 100644 --- a/python_3_oop/chapter02/menu.py +++ b/python_3_oop/chapter02/menu.py @@ -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)) diff --git a/python_3_oop/chapter02/notebook.py b/python_3_oop/chapter02/notebook.py index 02a26b9..65f4fa5 100644 --- a/python_3_oop/chapter02/notebook.py +++ b/python_3_oop/chapter02/notebook.py @@ -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