Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Python » Python program » Scope of Variable

Python program on scope of variable

This program create a double dimention int arrays, suffle its elements and then find saddle point if any

# Author: CppBuzz.com
# This programs shows the rules for variable & global scope in the program
# Date: 22nd Aug 2020


# LEFG Rule: local, enclosing, global, built-in scope

variable = 'Global variable'

def test():
    variable = 'Local variable'
    print(variable)  # prints 'Local variable'


if __name__ == '__main__':
    test()
    print(variable)  # prints 'Global variable'

Scope of variable in Python