BUG: Fur Trader (Python) didn't handle error case correctly

This commit is contained in:
Martin Thoma
2022-04-02 08:23:02 +02:00
parent 4b3b991273
commit 88fcd0b460

View File

@@ -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