You are not logged in.
Pages: 1
HELP!
I'm trying to make a Mafiya game in Python, but have run into problems. Here's what I'm worried about:
import random
def Start():
day = 0 #This variable definition should work...
DayTime()
...
Here's what I get when I run it:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
Start()
File "/Users/Rayment/Documents/Chase/games/Python/Mafiya!", line 5, in Start
DayTime()
File "/Users/Rayment/Documents/Chase/games/Python/Mafiya!", line 7, in DayTime
day = day + 1;
UnboundLocalError: local variable 'day' referenced before assignment
I know that means that my variable definition is wrong, but it should be right. What gives?
Linux FTW
Offline
Sorry to double post, but I noticed that a Windows machine with the same installation of Python doesn't have a single problem.
Linux FTW
Offline
Not a python programmer here, but it looks like day is declared locally instead of globally. This means that it won't exist in other local routines.
"In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..."
Offline
True, but that doesn't explain why it works on Windows, but not Mac.
Linux FTW
Offline
El error tipo "<pyshell#4>"es por error de impresion...
cambia el
print variable
que estes ejecutando por:
print str(variable)
debe funcionar, ojala te sirva
sorry... wrong language:
the error "<pyshell#4>" points to a print variable error
instead of:
print variable
use:
print str(variable)
I hope it can helps
Pages: 1