Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °
| |
|
|
You are not logged in. #1 2009-12-24 13:32:30
Python Variable Definition TroublesHELP! Code:import random
def Start():
day = 0 #This variable definition should work...
DayTime()
...Here's what I get when I run it: Code: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 assignmentI know that means that my variable definition is wrong, but it should be right. What gives? Linux FTW #3 2009-12-26 02:48:15
Re: Python Variable Definition TroublesNot 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..." #5 2010-01-16 17:30:22
Re: Python Variable Definition TroublesEl error tipo "<pyshell#4>"es por error de impresion... #6 2010-01-16 17:33:09
Re: Python Variable Definition Troublessorry... wrong language: |