Python bootcamp #100DaysOfCode #myNotes

This day was all about Control Flow and Logical Operators. It was a long day but I managed to do all the assignments.

Today's end project was to build a little text based game named Treasure Island.

``````#begin code
print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.")

left_right = input('You are at a cross road. Where do you want to go?
Type "left" or "right". ').lower()

if left_right == "left":
wait_swim = input('You have come to a lake. There is an island in the middle of the lake.
Type "wait" to wait for a boat. Type "swim" to swim across. ').lower()
if wait_swim == "wait":
which_door = input('You arrive at the island unharmed. There is a house with 3 doors.
One red, one yellow and one blue. Which colour do you choose? ').lower()
if which_door == "red":
print("You are burned by fire. Game Over!")
elif which_door == "blue":
print("You are eaten by a beast. Game Over!")
elif which_door == "yellow":
print("Yay! You win!")
else:
print("Game Over.")
else:
print("You are attacked by piranhas. Game Over!")
else:
print("You fall into a hole. Game Over!")
#end code
``````

When executed this game looks like this:

Welcome to Treasure Island.
Your mission is to find the treasure.
You are at a cross road. Where do you want to go? Type "left" or "right". Left
You have come to a lake. There is an island in the middle of the lake. Type "wait" to wait for a boat. Type "swim" to swim across. Wait
You arrive at the island unharmed. There is a house with 3 doors. One red, one yellow and one blue. Which colour do you choose? Blue
You are eaten by a beast. Game Over!