From 14772e3f2d4e83f7e4117451d66b086ea1a4d90a Mon Sep 17 00:00:00 2001 From: tmeissner Date: Mon, 1 Sep 2014 23:16:32 +0200 Subject: [PATCH] changed (internal) _remove_note() method to (not internal) method remove_note() --- python_3_oop/chapter02/menu.py | 2 +- python_3_oop/chapter02/notebook.py | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) 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