Explored some Python at Gork Learning. Worked on, Hour of Code: The Dark Tunnel – adventure game! Learned to use the if function to print out a predetermined action based on what the player chooses to do.
The code I used:
print("You are standing in the middle of the tunnel.")
print("Where would you like to go?")
action = input("> ")
if action == "forward":
print("You move further into the tunnel.")
if action == "backward":
print("You move back towards the tunnel entrance.")
The interactions looked like this:
You are standing in the middle of the tunnel.
Where would you like to go?
> forward
You move further into the tunnel.
You are standing in the middle of the tunnel.
Where would you like to go?
> backward
You move back towards the tunnel entrance.
No comments:
Post a Comment