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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -