0

次のコードはなぜですか:

exec("""
a = 3
def b():
  nonlocal a
  a = a + 1
b() #error occurs even without this call
print(a)
"""
)

)

このエラーを出してください:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 4
SyntaxError: no binding for nonlocal 'a' found

これは、テキスト/コードの比率を満たすための追加のテキストです。

4

1 に答える 1