Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Functions, Packing, and Unpacking Introduction to Functions Let's Talk About Scope

Jiyan Baran Bukun
Jiyan Baran Bukun
1,837 Points

What if function returns the num?

If the function return num at the end then will num be updated from 10 to 5? Thanks.

1 Answer

Steven Parker
Steven Parker
231,072 Points

Returning a value from the function will not affect the calling environment by itself.

Now if you wanted to change the original "num", you could also reassign it using that returned value:

num = set_num()