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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:13:49+00:00 2026-06-04T18:13:49+00:00

For an online course in python, I’m making a basic text-based adventure game in

  • 0

For an online course in python, I’m making a basic text-based adventure game in python.

Right now, I have a rudimentary inventory system that works through booleans for if the user has an object or not, and integers for limited items, such as ammo and whatnot.
Here is the code for the inventory system

def Inventory(self): #The inventory for the game.  I don't know how to program it properly, so this is my testing ground. 
#This will hold the boolean values to if the player has the items or not.  Another will be used to show the user the items

    street_clothes = False
    pistol = False
    ammo = 0
    phone = False

And this is the code where I am trying to modify the inventory function above

#Eric's apartment
 def Eric_Apartment(self):

    print "type in grab your gun"

    action = raw_input("> ")

    if action == "grab":
        self.Inventory(CR97) = True
    #   self.CR97_ammo += 15
    #   print CR97_ammo
    #   print self.CR97_ammo

    exit(1)

Attempting to run this program gets me this error:

python ex43.py
File "ex43.py", line 78
self.Inventory(CR97) = True
SyntaxError: can't assign to function call

Is there something else I’m supposed to do? I’m very new to python, and this is my first project on my own.

Here is the entire code, for reference

from sys import exit #allows the program to use the exit(1) code
from random import randint #allows the program to use a random number

class Game(object):

#quotes that pop up if the person dies, and also defines the start and self variables
 def __init__(self, start):
    self.quips = [
        "You lose!"
    ]
    self.start = start

 def Inventory(self): #The inventory for the game.  
#This will hold the boolean values to if the player has the items or not. 

    street_clothes = False
    pistol = False
    ammo = 0
    phone = False


#this function launches the game, and helps with the room transfer
 def play(self):
    next = self.start

    while True:
        print "\n---------"
        room = getattr(self, next)
        next = room( )

#if the user dies, or fails at the game, this is the function that is ran
 def death(self):
    print self.quips[randint(0, len(self.quips)-1)]
    exit(1)

#Welcome screen to the game
 def welcome_screen(self):
    print " place holder"
    return 'intro_screen'

#Intro screen to the game
 def intro_screen(self):

    print "place holder"

    action = raw_input("> Press any key to continue ")

    return 'Eric_Apartment'

#Eric's apartment
 def Eric_Apartment(self):

    print "type in grab your gun"

    action = raw_input("> ")

    if action == "grab":
        self.Inventory(CR97) = True
    #   self.CR97_ammo += 15
    #   print CR97_ammo
    #   print self.CR97_ammo

    exit(1)

a_game = Game("welcome_screen")
a_game.play()
  • 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-06-04T18:13:50+00:00Added an answer on June 4, 2026 at 6:13 pm

    That’s an amazingly perverse way to go about it. Why are you using a function to store data?

    Just have a player object, with an inventory array.

    I’d recommend using objects to model items too. Good use for for a class hierarchy. COuld have a base Item, with Subclasses SingleItem and StackableItem, etc.

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

Sidebar

Related Questions

I have joined Standford online course on Algorithms design and now I'm solving the
I've been going through an online UNIX course and have come across this question
I have a project which requires me to setup an subscription-based online learning site
I'm doing the following to try and determine whether display a course online based
I own an online game where you have a status box. Which you can
After watching the Stanford iTunesU CS193p online course I have quick question regarding the
Im trying to write a game of Yahtzee as part of an online course
I am taking the free Stanford database course online. I don't have any DB
About a week ago I have started a online course compilers at coursera.org. Today
In the Stanford iPhone course CS193P assignment 2 (free online course), the step through

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.