Skip to content

Commit

Permalink
Reorganize loop in level_prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyn committed Aug 16, 2021
1 parent e1fc65a commit 0ba98fb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/levelloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,16 @@ def level_prompt(self, scrn: curses.window) -> str:
curses.noecho()
if raw_choice == QUIT:
raise KeyboardInterrupt
else:
try:
choice = int(raw_choice)
if choice in range(1, len(level_names) + 1):
break
except ValueError:
pass
prompt = invalid_input_prompt

try:
choice = int(raw_choice)
if choice in range(1, len(level_names) + 1):
break
except ValueError:
pass

prompt = invalid_input_prompt

choice -= 1
chosen_level_name = level_names[choice]
return chosen_level_name.rstrip()

0 comments on commit 0ba98fb

Please sign in to comment.