Skip to content

Commit

Permalink
Fix dict KeyError (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
hulikau authored and donnemartin committed Apr 26, 2018
1 parent fb66242 commit e50e200
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions solutions/object_oriented_design/lru_cache/lru_cache.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
" \n",
" Accessing a node updates its position to the front of the LRU list.\n",
" \"\"\"\n",
" node = self.lookup[query]\n",
" node = self.lookup.get(query)\n",
" if node is None:\n",
" return None\n",
" self.linked_list.move_to_front(node)\n",
Expand All @@ -97,7 +97,7 @@
" If the entry is new and the cache is at capacity, removes the oldest entry\n",
" before the new entry is added.\n",
" \"\"\"\n",
" node = self.lookup[query]\n",
" node = self.lookup.get(query)\n",
" if node is not None:\n",
" # Key exists in cache, update the value\n",
" node.results = results\n",
Expand Down

0 comments on commit e50e200

Please sign in to comment.