26 lines
896 B
Python
26 lines
896 B
Python
|
import random
|
||
|
|
||
|
# The fish is hiding in a randomly chosen pond between 1 and 5
|
||
|
fish_pond = random.randint(1, 5)
|
||
|
|
||
|
print("Welcome to FindFish!")
|
||
|
print("A fish is hiding in one of five ponds, numbered 1 through 5. You have three guesses to find it.")
|
||
|
|
||
|
# The player has three attempts
|
||
|
for attempt in range(1, 4):
|
||
|
guess = int(input("Guess which pond the fish is hiding in (1-5): "))
|
||
|
|
||
|
if guess < 1 or guess > 5:
|
||
|
print("Please choose a pond between 1 and 5.")
|
||
|
elif guess < fish_pond:
|
||
|
print("Try guessing a higher pond number.")
|
||
|
elif guess > fish_pond:
|
||
|
print("Try guessing a lower pond number.")
|
||
|
else:
|
||
|
break # This exits the loop if the guess is correct
|
||
|
|
||
|
if guess == fish_pond:
|
||
|
print(f"Congratulations! You found the fish in pond {fish_pond} on attempt {attempt}!")
|
||
|
else:
|
||
|
print(f"Sorry, you did not find the fish. It was in pond {fish_pond}.")
|