⇤ ← Revision 1 as of 2012-04-24 05:52:28
1028
Comment:
|
1025
|
Deletions are marked like this. | Additions are marked like this. |
Line 11: | Line 11: |
## def fun(): | def fun(): |
Asking for Help: ...
The following puzzles me: Both a and b are globals. Both are assigned an initial value in fun(). But b is considered unassigned in fun1().
def fun():
- global a,b a = [0]*1 b = 0 fun1()
def fun1():
- a[0] += 1 print('a[0]: ', a[0]) b += 1 print('b: ', b)
fun()
- b += 1
UnboundLocalError: local variable 'b' referenced before assignment
When answering questions, add the CategoryAskingForHelpAnswered category when saving the page. This will move the link to this page from the questions section to the answers section on the Asking for Help page.