Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 27, 2022 04:49 pm GMT

python code for a treasure hunt game

Learning python has made me realize the importance of repetition. Especially if one is new to it.

Today, i was able to write a basic code for a treasure hunt game without guidiance

print("Welcome to Treasure Island.")print("Your mission is to find the treasure.") first_choice = input('You\re on a crossroad, where do you want to go? Left or right
').lower()if first_choice == 'left': second_choice = input('You\ve come to a lake. There is an island in the middle of the lake. Do you wait or swim?
"').lower() if second_choice == 'wait': third_choice = input('You have arrived the island unharmed. There is a house with 3 doors. One red, one yellow and one blue. Which colour do you choose?
').lower() if third_choice == 'blue': print('Eaten by beasts. Game over') elif third_choice == 'red': print('burned by fire. Game over') elif third_choice == 'yellow': print('You win') else: print('Game over.') else: print('swallowed by a shark. Game over')else: print('oops! wrong choice. Game over')

Original Link: https://dev.to/frankpromise/python-code-for-a-treasure-hunt-game-4hkn

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To