Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:17:46+00:00 2026-05-28T06:17:46+00:00

I am currently working on Learn Python the Hard Way by Zed Shaw. I

  • 0

I am currently working on Learn Python the Hard Way by Zed Shaw. I am struggling with Exercise 43, which instructs me to create a text game with the following properties:

  • Uses more than 1 file
  • One class per “room”

So far I have started two files, one for the runner and one with the rooms:

game_runner.py

from game_map import *

class Runner(object):
    def __init__(self, start):
        self.start = start

    def play(self):
        next_room = self.start

        while True:
            print '\n'
            print '-' * 7
            print next_room.__doc__
            next_room.proceed()

firstroom = Chillin()

my_game = Runner(firstroom)

my_game.play()

game_map.py

from sys import exit

class Chillin(object):
    """It's 8pm on a Friday night in Madison. You're lounging on the couch with your 
roommates watching Dazed and Confused. What is your first drink?
    1. beer
    2. whiskey
    3. vodka
    4. bowl
"""
    def __init__(self):
        self.prompt = '> '

    def proceed(self):
        drink = raw_input(self.prompt)

        if drink == '1' or drink == 'beer':
            print '\n Anytime is the right time.'
            print 'You crack open the first beer and sip it down.'
            room = Pregame()
            return room
        #rest of drinks will be written the same way


class Pregame(object):
    """It's time to really step up your pregame.
How many drinks do you take?
"""

    def proceed(self):
        drinks = raw_input('> ')
    #and so on

My problem is that I cannot get the game_runner to proceed to the next room. When I run it, it plays an infinite loop of the first room: prints the docstring for Chillin(), asks for input, then repeats.

How can I change my runner and/or map to return the next class, i.e. Pregame(), after entering a correct response in the first class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:17:47+00:00Added an answer on May 28, 2026 at 6:17 am

    I think all you need to do (if I follow your code correctly) is change this:

    next_room.proceed()
    

    to this:

    next_room = next_room.proceed()
    

    You’re never re-assigning to the variable that you’re using inside your while True: loop, so you get the same behavior forever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im currently working with an API which requires we send our collection details in
I am currently working on a project and my goal is to locate text
I'm currently working on a small 2D game-engine in C++, but I am now
I am currently trying to learn J2ME and build a connect four game (some
Currently i am working on a desktop application which consists mathematical analysiss.I am using
Working in F# has lead me to learn about Haskell. I'm currently on chapter
I'm right at the beginning of trying to learn Actionscript 3. I'm currently working
Im currently trying to learn Networking with Python asyncore and pyqt4. I coded a
Currently working in the deployment of an OFBiz based ERP, we've come to the
Currently working on a VBScript to automate some of the dirty PST ingestion work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.