I am currently in the process of programming a text-based adventure in Python as a learning exercise. I want "help" to be a global command, stored as values in a list, that can be called at (essentially) any time. As the player enters a new room, or the help options change, I reset the help_commands
list with the new values. However, when I debug the following script, I get a 'list' object is not callable
TypeError.
I have gone over my code time and time again and can't seem to figure out what's wrong. I'm somewhat new to Python, so I assume it's something simple I'm overlooking.
player = {"name": "","gender": "","race": "","class": "","HP": 10,
}global help_commands
help_commands = ["Save", "Quit", "Other"]def help():sub_help = '|'.join(help_commands)print "The following commands are avalible: " + sub_helpdef help_test():help = ["Exit [direction], Open [object], Talk to [Person], Use [Item]"]print "Before we go any further, I'd like to know a little more about you."print "What is your name, young adventurer?"player_name = raw_input(">> ").lower()if player_name == "help":help()else:player['name'] = player_nameprint "It is nice to meet you, ", player['name'] + "."help_test()
Edit:
You're like my Python guru, Moses. That fixed my problem, however now I can't get the values in help_commands to be overwritten by the new commands:
player = {"name": "","gender": "","race": "","class": "","HP": 10,
}# global help_commands
help_commands = ["Save", "Quit", "Other"]def help():sub_help = ' | '.join(help_commands)return "The following commands are avalible: " + sub_helpdef help_test():print help()help_commands = ["Exit [direction], Open [object], Talk to [Person], Use [Item]"]print help()print "Before we go any further, I'd like to know a little more about you."print "What is your name, young adventurer?"player_name = raw_input(">> ").lower()if player_name == "help":help()else:player['name'] = player_nameprint "It is nice to meet you, ", player['name'] + "."help_test()
Thoughts?