Wednesday, April 30, 2014

Day 25

Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Learned to use the if and else functions to print out a predetermined response based on what the player chooses to do.

The code I used:
print("What action would you like to do?")
guess = input("> ")
if guess == "look":
print("You look around.")
else:
print("You cannot do that.")

The interactions looked like this:
What action would you like to do?
> look
You look around.

What action would you like to do?
> run
You cannot do that.

No comments:

Post a Comment