python - Why does this not identify the variable s? -


this question has answer here:

consider python code:

def lower_it(s):     def charr():         s = s.lower() #error         ans = s         return ans     return charr() 

the place have written #error gives error because says s referenced before assignment. don't think should give error because if call function lower_it('hello'), should make s = 'hello' , s in scope of charr, right? variable defined in body of lower_it should in scope of charr, right?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Python Tornado package error when running server -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -