Skip to content

Commit

Permalink
Merge pull request #1130 from daredevil0905/master
Browse files Browse the repository at this point in the history
fix: ask user again for valid column input in connect_four instead of throwing error
  • Loading branch information
pnhofmann authored Aug 28, 2023
2 parents 369a0e0 + e2af2ee commit e13af5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion jarviscli/plugins/connect_four.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,15 @@ def game(jarvis, s):

printBoard()
while True:
column = int(input('Pick a column (1-7):\n'))

# Make sure column is numeric. If not then ask user for numeric input again instead of throwing error.
notNumericInputFlag = True
while notNumericInputFlag == True:
try:
column = int(input('Pick a column (1-7):\n'))
notNumericInputFlag = False
except ValueError:
print("Enter a valid numeric input.")
column -= 1

# Make sure column is inbounds
Expand Down
2 changes: 1 addition & 1 deletion jarviscli/plugins/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def calc(jarvis, s, calculator=sympy.sympify, formatter=None, do_evalf=True):
s = format_expression(s)

try:
result = calculator(jarvis, s)
result = calculator(s)
except sympy.SympifyError:
jarvis.say("Error: Something is wrong with your expression", Fore.RED)
return
Expand Down

0 comments on commit e13af5c

Please sign in to comment.