← Quiz: Scope and Closures: all 10 questions
Quiz: Scope and Closures · Question 1 of 10
In which order does Python search for a name?
In which order does Python search for a name?
- A.Global, Local, Built-in, Enclosing
- B.Local, Enclosing, Global, Built-in
- C.Built-in, Global, Enclosing, Local
- D.Local, Global, Enclosing, Built-in
Answer & explanation
Correct answer: Local, Enclosing, Global, Built-in
The LEGB rule: innermost scope first, built-ins last.
Can you get the rest right without peeking?
Take the timed Quiz: Scope and Closures quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →