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 7702223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:10:45+00:00 2026-05-31T23:10:45+00:00

I am having an issue trying to make a small text-fantasy type game involving

  • 0

I am having an issue trying to make a small text-fantasy type game involving classes for each type of entity (a wall, the player, a book etc). I have a class called room that looks like this:

class Room:

    def __init__(self, desc, items, wallF, wallB, wallL, wallR, isdark):
        self.desc = desc
        self.items = items
        self.wallF = wallF
        self.wallB = wallB
        self.wallL = wallL
        self.wallR = wallR
        self.isdark = False

now I have two rooms that are defined like this (not saying that its right):

roomstart = Room('There is a hole in the ceiling where you seemed to have fallen through, there is no way back up...', [candle], True, False, False, False, False)
room2 = Room('You enter a small cobblestone cavort. It is dark, and the smell of rot pervades you', [spellbook], False, True, False, True, True)

now, the problem is this: when I run the program it works fine up until I try to take the candle from roomstart, it then spits out the error that the candle is not in a list:

(<type 'exceptions.ValueError'>, ValueError("'candle' is not in list",), <traceb
ack object at 0x00B8D648>)

(yes, I did use sys.exc_info())

each object, (the candle, a dagger, a robe etc) has a class as well:

class Object:

    def __init__(self, desc, worth, emitslight, readable, wearable, name):
        self.desc = desc
        self.worth = worth
        self.emitslight = emitslight
        self.readable = readable
        self.wearable = wearable
        self.name = name

here is the code for user input:

def handleinput():
global moves
room = Player.location
if room.isdark == True:
    print 'It is rather dark in here...'
else:
    print room.desc, 'You see here:',
    for i in room.items:
        print i.name
input = str(raw_input('What now? ')).lower()
if 'look' in input:
    if room.isdark==True:
        print "You can't see anything! Its too dark."
    else:
        print 'You see:',room.desc, room.items.name
        if room.wallF == True:
            print 'There is an exit to the front.'
        elif room.wallB == True:
            print 'There is an exit behind you.'
        elif room.wallL == True:
            print 'There is an exit to your left.'
        elif room.wallR == True:
            print 'There is an exit to your right.'

elif 'grab' in input:
    if room.isdark==True:
        print 'You flail about blindly in the dark room!'
    else:
        input2 = str(raw_input('Take what? '))
        try:
            popp = room.items.index(input2)
            print popp
        except:
            print sys.exc_info()
            print input2.title(),"doesn't exist!"
        else:
            print "You take the",input2,"and store it in your knapsack."
            room.items.pop(popp)
            Player.inventory.append(input2)

elif 'wipe face' in input:
    os.system('cls')
moves += 1
  • 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-31T23:10:46+00:00Added an answer on May 31, 2026 at 11:10 pm

    The object candle is in the list, but the string 'candle' is not. You may wish to solve this with a dictionary of the objects:

    objects = {}
    objects['candle'] = candle
    objects['robe'] = robe
    ...
    

    Then, you can find the index of the item via

    popp = room.items.index(objects[input2])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an NSMutableArray usable in multiple classes. I'm having an issue
I'm having an issue with a game that I'm trying to make. Here is
I am trying to make the game Asteroids. My issue I have right now,
I am having an issue trying to deal with timezones in the JQuery date/time
I'm having an issue when trying to do something which should be as easy
I am having a big issue trying to delete from an UITableView. Just for
I'm having this issue when trying to use an ASPX page from a referenced
One of my users is having an issue when trying to open an Excel
Having an issue with random individuals trying to access an intranet site with a
The issue I'm having is issue with is I'm trying to get the paintComponent

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.