In what order does Python search scopes when resolving a name (the LEGB rule)?
Correct answer B. Local, Enclosing, Global, Built-in
Explanation
Python first looks in the local scope of the current function, then in the scopes of any enclosing functions, then in the module's global scope, and finally in the built-in namespace. This is why a local variable can shadow a built-in such as len.
Answer checked How we write and check questions
Discussion