New "Choose Your Own Adventure" Game

Having a "Choose Your Own Adventure" style game for readers to look at was suggested to me, so I quickly wrote one up. The code is designed to be very simple, despite its length. There is no accompanying chapter, but I do provide a short description page.

The source code:

http://inventwithpython.com/extra/dragon2.py

The description page:

http://inventwithpython.com/extra/dragon2.html

These links are also on the Extras page on the main site.

4 thoughts on “New "Choose Your Own Adventure" Game

  1. how hard would it be to integrate images into this? I was thinking like a background image per each option?

    also I got this error:
    teamcoltra@paradoxicon ~/Downloads $ python '/home/teamcoltra/Downloads/dragon2.py'
    File "/home/teamcoltra/Downloads/dragon2.py", line 6
    print('1 to ' + str(numberOfPaths) + '> ', end='')
    ^
    SyntaxError: invalid syntax

    1. This error is because you are using Python 2. I assume you are using OS X, which comes with Python 2 installed by default. You can google Python 3 installation instructions.

      I was able to figure out this error because in Python 2, "print" is not a function, so the end="" part causes a syntax error.

  2. >>> import dragon2.py
    Traceback (most recent call last):
    File "", line 1, in
    File "dragon2.py", line 6
    print('1 to ' + str(numberOfPaths) + '> ', end='')
    ^

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>