LearnFrenzy
Sign in Take a free test

Functions · Functions MCQ · Question 8

The LEGB rule Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

In what order does Python look up a name?

  • A Local, Enclosing, Global, Built-in Correct
  • B Global, Local, Built-in, Enclosing
  • C Built-in, Global, Enclosing, Local
  • D Local, Global only
Correct Answer: Option A

The first scope that has the name wins, which is how a local variable can hide a global or a built-in.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links