it' later called)each remembers its own value for idef makeactions()acts [for in range( )acts append(lambda xi=ii *xreturn acts acts makeactions(acts[ ]( acts[ ]( acts[ ]( acts[ ]( use defaults instead remember current * * * * this seems an implementation artifact that is prone to changeand may become more important as you start writing larger programs we'll talk more about defaults in and lambdas in so you may also want to return and review this section later arbitrary scope nesting before ending this discussionwe should note that scopes may nest arbitrarilybut only enclosing function def statements (not classesdescribed in part viare searched when names are referenceddef () def ()def ()print(xf ( (found in ' local scopef ( python will search the local scopes of all enclosing defsfrom inner to outerafter the referencing function' local scope and before the module' global scope or built-ins howeverthis sort of code is even less likely to pop up in practice againin pythonwe say flat is better than nestedand this still holds generally true even with the addition in the section "function gotchason page we'll also see that there is similar issue with using mutable objects like lists and dictionaries for default arguments ( def ( =[]))--because defaults are implemented as single objects attached to functionsmutable defaults retain state from call to callrather then being initialized anew on each call depending on whom you askthis is either considered feature that supports another way to implement state retentionor strange corner of the languagemore on this at the end of scopes and nested functions