Skip to content

Commit 7f54af4

Browse files
committed
Sync materials with the tutorial
1 parent 653e1be commit 7f54af4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

basic-input-output-in-python/adventure_game.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
enemy_health = 3
55

66
while health > 0 and enemy_health > 0:
7-
if input("Attack or Run? ").lower() == "attack":
7+
# Normalize input to handle extra spaces and case variations.
8+
action = input("Attack or Run? ").strip().lower()
9+
if action not in {"attack", "run"}:
10+
print("Invalid choice. Please type 'Attack' or 'Run'.")
11+
continue
12+
13+
if action == "attack":
814
enemy_health -= 1
915
print("You hit the enemy!")
1016
# Implement a 50% chance that the enemy strikes back.

basic-input-output-in-python/guess_the_number.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
if guess == number:
77
print("You got it!")
88
else:
9-
print(f"Sorry, the number was {number}.")
9+
print("Sorry, the number was", number)

0 commit comments

Comments
 (0)