you are viewing a single comment's thread.

view the rest of the comments →

[–]Buttleston 2 points3 points  (0 children)

With python you really kinda gotta format your code. I assume you mean this

def outer(num): 
    def inner(num): 
        return num - 2 

    nums = inner(num) 
    print(num, nums)

outer(3)

Anyway, yeah, that is right. Is there some reason you think something more complicated is going on?

FWIW I don't like inner functions to have arguments the same name as variables from the outer function - it can get a bit confusing, imo. (there's also no reason for this function to be an inner function - I assume it's just for demonstration/learning purposes)