diff --git a/basic-input-output-in-python/adventure_game.py b/basic-input-output-in-python/adventure_game.py index e634754a35..1d3e363d81 100644 --- a/basic-input-output-in-python/adventure_game.py +++ b/basic-input-output-in-python/adventure_game.py @@ -4,7 +4,13 @@ enemy_health = 3 while health > 0 and enemy_health > 0: - if input("Attack or Run? ").lower() == "attack": + # Normalize input to handle extra spaces and case variations. + action = input("Attack or Run? ").strip().lower() + if action not in {"attack", "run"}: + print("Invalid choice. Please type 'Attack' or 'Run'.") + continue + + if action == "attack": enemy_health -= 1 print("You hit the enemy!") # Implement a 50% chance that the enemy strikes back. diff --git a/basic-input-output-in-python/guess_the_number.py b/basic-input-output-in-python/guess_the_number.py index 3d485326ef..437b5d7af3 100644 --- a/basic-input-output-in-python/guess_the_number.py +++ b/basic-input-output-in-python/guess_the_number.py @@ -6,4 +6,4 @@ if guess == number: print("You got it!") else: - print(f"Sorry, the number was {number}.") + print("Sorry, the number was", number)