Tuesday, April 22, 2014

Day 17

Explored some Python at Gork Learning, wrote a program in which bot asks are we there yet, then reacts based on your comment, added an if statement..

The code I used:
# Code for "Interacting with bot."
answer = "no"
while answer != "yes":
  if answer == "nearly":
    print("Yay!")
  print("Are we there yet?")
  answer = input()
print("Yes! We are finally here.")


The interaction looked like this:
Are we there yet?
no
Are we there yet?
nearly
Yay!
Are we there yet?
nope
Are we there yet?
yes
Yes! We are finally here.

No comments:

Post a Comment