1
votes

This is a part of my program. It gives the error NameError: name 'urlss' is not defined

def testfunc():
  urlss = "hey"
  return urlss

print urlss

Why does this occur?

1

1 Answers

9
votes

urlss is a variable local to the scope of testfunc(); it cannot be accessed elsewhere. You might mean

print testfunc()

which in this case prints urlss, since that's what testfunc() returns.