import random
number_of_doors = 5
# Display welcome messages
print("Welcome to the Goblin Hunt")
print("An award-winning game full of adventure and excitement (!)")
# Get player name
player_name = input("What is your name? ")
print( player_name + ", a goblin is hiding in one of the kitchen cupboards. Do you think that you can find it?")
print("|_|" * number_of_doors)
goblin_position = random.randint(1, number_of_doors)
keep_trying = True
# Main game loop
while keep_trying:
guessed_position = input("Can you guess where the goblin is hiding? ")
guessed_position = int(guessed_position)
if guessed_position == goblin_position: # If player guesses correctly
print("Well done. You've found the goblin.")
keep_trying = False
else: # If player's guess is incorrect
print("No, sorry. The goblin is still hiding somewhere.")
print("Thank you for playing. Now get back to work!")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter