mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-06 12:51:27 -08:00
BUG: Fur Trader (Python) didn't handle error case correctly
This commit is contained in:
@@ -112,15 +112,14 @@ def get_furs_purchase():
|
|||||||
print("KINDS OF PELTS: MINK, BEAVER, ERMINE AND FOX.")
|
print("KINDS OF PELTS: MINK, BEAVER, ERMINE AND FOX.")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
for i in range(len(FUR_NAMES)):
|
while len(results) < len(FUR_NAMES):
|
||||||
print("HOW MANY " + FUR_NAMES[i] + " DO YOU HAVE")
|
print(f"HOW MANY {FUR_NAMES[len(results)]} DO YOU HAVE")
|
||||||
count_str = input(">> ")
|
count_str = input(">> ")
|
||||||
try:
|
try:
|
||||||
count = int(count_str)
|
count = int(count_str)
|
||||||
results.append(count)
|
results.append(count)
|
||||||
except Exception:
|
except Exception: # invalid input, prompt again by re-looping
|
||||||
# invalid input, prompt again by re-looping
|
pass
|
||||||
i -= 1
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user