I know why we need to declare nonlocal in Python and am a bit confused about the following example. Without nonlocal records
in line 276, records
in line 277 is not defined. However, records
in line 289 can be used without any error.
And the following is the situation with nonlocal and it works well.