Skip to content

Commit

Permalink
Sync materials with the tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
bzaczynski committed Nov 21, 2024
1 parent 653e1be commit 7f54af4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion basic-input-output-in-python/adventure_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion basic-input-output-in-python/guess_the_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 7f54af4

Please sign in to comment.