Interactive Stories with Input

You can use if statements to make a story interactive where the reader picks from several possible next actions. The input method will display the string and return what the user types. You can check if two strings have the same characters using == in Python.

    csp-13-2-1: What is the last thing printed if the user answers left?
  • The room is pitch black.
  • This line will be printed when the user enters in.
  • A ghost appears at the end of the hall.
  • This line will printed when the user enters left.
  • A greenish light is visible in the distance.
  • This line will printed when the user enters right.
  • None of the above is printed.
  • If the user enters something besides in, left, or right none of the logical expressions will be true and none of these will be printed.
    csp-13-2-2: What is the printed if the user answer something other than in, left, or right?
  • The room is pitch black.
  • This line will be printed when the user enters in.
  • A ghost appears at the end of the hall.
  • This line will printed when the user enters left.
  • A greenish light is visible in the distance.
  • This line will printed when the user enters right.
  • None of the above is printed.
  • None of the conditions will be true if the user enters something other than in, left, or right so none of these will be printed.

What should the program do if the user enters something besides in, left, or right? Fix the code above to let the user know what went wrong. Also add another possibility like “out”.

Next Section - Fortune Teller