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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:26:31+00:00 2026-06-14T13:26:31+00:00

I started to code a text-based game in a Main program which call functions

  • 0

I started to code a text-based game in a
Main program which call functions in file-modules.

There is a particular case where a file-module and a function are called and the function (in the module) should append a list in the Main() program (a global variable).

The problem is it cannot append it.

So, more concretely, in the game, the player enters a room (RoomA2) and there’s an object (sword).
The player can pick it up (and I want the function to remove it from the list called object_room_a2 ) and put the sword in his bag.
So, the bag is a global list (called object_list) in the Main() program.

Please the codes below, thanks for the help!

object_list = []

def main():
    print('stuff.. What do you want to do? (1) do this; (2) do that')
    choice = int(input('Choice --> '))

    if choice == 1 :
        RoomA2.room_a2()
    elif choice == 2 :
        RoomB1.room_b1()

def room_a2():
    object_room_a2 = ['sword']
    print('stuff.. What do you want to do? (1) do this; (2) do that')
    choix = int(input('choix --> '))

    if choix == 1:
        object_room_a2.remove('sword')
        object_list.append('sword')

    if choix == 2:
        RoomA1.room_a1()
  • 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-14T13:26:32+00:00Added an answer on June 14, 2026 at 1:26 pm

    The problem is that every time room_a2 is called, object_room_a2 is re-initialized so the sword will keep reappearing.

    In general, this is a very complicated way to do what you are trying to do. A player object and a collection of room objects would make for far less code, but I assume that you are a beginner and might want to get a few rooms working this way first.

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

Sidebar

Related Questions

A simulation program I'm using requires a text based input file. I need to
Ive inherited some code which started out as an Android project but really is
I m developin Tab based Application in which first activity contain one edit text
So I've written some code in Ruby to split a text file up into
I have just started to code for Mac OS X and I'm very excited
I have just installed C# 2008 Express Edition 2008 and started writing code. My
I'm new to PHP, started with Code Igniter and MAMP. I start the server
I started with the code from simplemodal, and modified to suit my needs. That
I have not started creating the code so I don't have anything to show,
Some assertions in my code just started acting strangely, and I was wondering if

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.