Answers for "how does scope work in python"

3

python variable scope

a = 5

def f1():
  a = 2
  print(a)
  
print(a)   # Will print 5
f1()       # Will print 2
Posted by: Guest on May-20-2020
3

how does scope work in python

a = 5
b = 3

def f1():
  a = 2
  print(a)
  print(b)
  
print(a)   # Will print 5
f1()       # Will print 2 and 3
Posted by: Guest on July-11-2020

Code answers related to "how does scope work in python"

Python Answers by Framework

Browse Popular Code Answers by Language