0

Sorry if this too naive..

global name
name=""

def namecheck(lastname):
    if name:
        name=lastname+name
    else:
        name=lastname

    print name

namecheck("ravi")

In a code like this how do access and modifythe variable name inside the function without having to pass it as an argument.

Right now I have this error: UnboundLocalError: local variable 'name' referenced before assignment

0 Answers0