I am comfused about the name behavior of Python in recursion

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Oct 6 01:03:37 EDT 2016


380162267qq at gmail.com wrote:
> def rec(a):
> 	a+=1
> 	if a<10:
> 		rec(a)
> 	print(a)
> 
> rec(0) gives me 10....1 normally.Why it works? Because of the stack memory management?

Yes. There isn't just one 'a' here, there's a different one
each time rec is called.
> 
> Thank you



More information about the Python-list mailing list