How to use local variable in function in Python

1 Answer

0 votes
def function():
    # print(s) UnboundLocalError: local variable 's' referenced before assignment
    s = "Java"
    print(s)


s = "Python"
function()


'''
run:

Java

'''

 



answered Dec 15, 2017 by avibootz

Related questions

...