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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:30:23+00:00 2026-06-10T21:30:23+00:00

I’m currently going through the book Learning Python The Hard Way, and I’m trying

  • 0

I’m currently going through the book “Learning Python The Hard Way”, and I’m trying to make a simple game. In this game, I want to be able to pick up at item “Flashlight” in one room, to be able to get into another room. I can, however, not make it work 🙁

So the question is, how do I carry the same list through several functions, and how do I put things in it? I want to be able to put multiple things in it.

I tried to call the pick() function within it self, but keep getting a “TypeERROR: ‘str’ is not callable, though I am providing my function with a list?

Hope you can help me out, thanks 🙂

Code:

def start(bag):
        print "You have entered a dark room"
        print "You can only see one door"
        print "Do you want to enter?"

        answer = raw_input(">")

        if answer == "yes":
            light_room(bag)
        elif answer == "no":
            print "You descidede to go home and cry!"
            exit()
        else:
            dead("That is not how we play!")

def light_room(bag):
    print "WOW, this room is amazing! You see magazines, cans of ass and a flashlight"
    print "What do you pick up?"
    print "1. Magazine"
    print "2. Cans of ass"
    print "3. Flashlight"

    pick(bag)

def pick(bag):    
    pick = raw_input(">")

    if int(pick) == 1:
        bag.append("Magazine")
        print "Your bag now contains: \n %r \n" % bag
    elif int(pick) == 2:
        bag.append("Can of ass")
        print "Your bag now contains: \n %r \n" % bag
    elif int(pick) == 3:
        bag.append("Flashlight")
        print "Your bag now contains: \n %r \n" % bag                    
    else:
        print "You are dead!"
        exit()

def start_bag(bag):
    if "flashlight" in bag:
        print "You have entered a dark room"
        print "But your flashlight allows you to see a secret door"
        print "Do you want to enter the 'secret' door og the 'same' door as before?"

        answer = raw_input(">")

        if answer == "secret":
            secret_room()
        elif answer == "same":
            dead("A rock hit your face!")
        else:
            print "Just doing your own thing! You got lost and died!"
            exit()
    else:
        start(bag)

def secret_room():
    print "Exciting!"
    exit() 

def dead(why):
    print why, "You suck!"
    exit()

bag = []
start(bag)
  • 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-10T21:30:25+00:00Added an answer on June 10, 2026 at 9:30 pm

    I tried to call the pick() function within it self, but keep getting a “TypeERROR: ‘str’ is not callable, though I am providing my function with a list?

    The problem here is that in this line:

    def pick(bag):    
        pick = raw_input(">")
    

    you bind pick to a new value (a str) so it doesn’t reference a function anymore. Change that to something like:

    def pick(bag):    
        picked = raw_input(">")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.