Skip to content

Commit

Permalink
refactor: use builtin function rather than custom implementation to i…
Browse files Browse the repository at this point in the history
…mprove readability
  • Loading branch information
mecaneer23 committed Jul 19, 2024
1 parent 2683127 commit ead724e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,7 @@ def get_input(self) -> Direction:
return Direction.NONE
if key == -1: # no key provided
return self._direction
try:
return keys[key]
except KeyError:
return Direction.NONE
return keys.get(key, Direction.NONE)

def get_new_head(self) -> Location:
"""Return the location of the snake's new head"""
Expand Down

0 comments on commit ead724e

Please sign in to comment.