| | |
text adventure game "local variable refferenced before assignment"
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 19
Reputation:
Solved Threads: 0
(new code)
so, my new error message is 'local variable 'gold' refferenced before assignment.'
now what?
so, my new error message is 'local variable 'gold' refferenced before assignment.'
now what?
•
•
Join Date: Apr 2008
Posts: 19
Reputation:
Solved Threads: 0
it's in the link...in the link is the whole code, but here is some....
and whenever run the program and enter that command, it gives me that error and quits...
python Syntax (Toggle Plain Text)
# if prompt_hou == 'examine table': print '''There are a lot of car magazines here. You flip through them and find 5 gold!''' gold = gold+5 prompt_house()
and whenever run the program and enter that command, it gives me that error and quits...
•
•
Join Date: Apr 2008
Posts: 19
Reputation:
Solved Threads: 0
yeah, i did that at the beginning..
but it still gives me that error...
python Syntax (Toggle Plain Text)
# #better text adventure test #Made by J. G. S. gold = 0 def start(): print '''You slowly open your eyes and find yourself lying on the ground. You get up slowly, looking around as you do, and here is what you see. As far as you can tell, you are in the middle of a field with tall grass. You cannot see that good unless you jump. You see a sign off to the north.'''
but it still gives me that error...
If the first code you showed is part of a function you have to tell it that gold is a global variable, start your function code with
python Syntax (Toggle Plain Text)
global gold
Last edited by sneekula; Apr 6th, 2008 at 2:24 pm.
No one died when Clinton lied.
•
•
Join Date: Apr 2008
Posts: 19
Reputation:
Solved Threads: 0
How would I do that? I tried adding global gold right before the gold = 0...but I got the same error. And i've also tried putting global gold like this:
but then it gives me "Invalid syntax"
what do I do?
python Syntax (Toggle Plain Text)
def start(global gold): print '''You slowly open your eyes and find yourself lying on the ground. You get up slowly, looking around as you do, and here is what you see. As far as you can tell, you are in the middle of a field with tall grass. You cannot see that good unless you jump. You see a sign off to the north.'''
but then it gives me "Invalid syntax"
what do I do?
![]() |
Other Threads in the Python Forum
- Previous Thread: text adventure game problem!
- Next Thread: No documentation on reading in int from file
Views: 1073 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for Python
advanced anydbm app assignment bash beginner bits bluetooth calling chmod cmd code convert data decimals dictionary dynamic dynamically examples excel external file float format ftp function gnu gui homework http import input itunes jaunty java keycontrol leftmouse line linux list lists loan loop maintain millimeter module mouse newb number numbers output parsing path pointer port prime program programming projects push py-mailer py2exe pygame pyglet pyqt python random recursion recursive scrolledtext slicenotation smtp split ssh string strings table tennis terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode update urllib urllib2 variable variables ventrilo web webservice windows wxpython xlib






