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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -