diff --git a/stacks_queues/queue_list/queue_list.py b/stacks_queues/queue_list/queue_list.py index 878f087..831e1ce 100644 --- a/stacks_queues/queue_list/queue_list.py +++ b/stacks_queues/queue_list/queue_list.py @@ -24,14 +24,11 @@ class Queue(object): # Empty list if self.first is None and self.last is None: return None - + data = self.first.data # Remove only element from a one element list - elif self.first == self.last: - data = self.first.data + if self.first == self.last: self.first = None self.last = None - return data else: - data = self.first.data self.first = self.first.next - return data \ No newline at end of file + return data \ No newline at end of file diff --git a/stacks_queues/queue_list/queue_list_solution.ipynb b/stacks_queues/queue_list/queue_list_solution.ipynb index 07c0d9a..4a20680 100644 --- a/stacks_queues/queue_list/queue_list_solution.ipynb +++ b/stacks_queues/queue_list/queue_list_solution.ipynb @@ -142,17 +142,14 @@ " # Empty list\n", " if self.first is None and self.last is None:\n", " return None\n", - "\n", + " data = self.first.data\n", " # Remove only element from a one element list\n", - " elif self.first == self.last:\n", - " data = self.first.data\n", + " if self.first == self.last:\n", " self.first = None\n", " self.last = None\n", - " return data\n", " else:\n", - " data = self.first.data\n", " self.first = self.first.next\n", - " return data" + " return data" ] }, { @@ -289,21 +286,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.4.3" } }, "nbformat": 4,