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

Robbie Baker
Robbie Baker
3,700 Points

I understood this video but once i added a print function to show the values it also returns None. I don't know why.

code: def my_function(arg1, arg2, arg3, arg4): print(arg1) print(arg2) print(arg3) print(arg4)

my_function("Hello", "I", "love", "python")

packing example

def packer(*pkr): print(pkr) for val in pkr: print (val)

print(packer("Hello", "I", "love", "python"))

The return shows both ways to run this function but the last line returns None as well. I would like to figure out why that print function is returning both the tuple and None. It works perfect if i remove the print function as follows:

packer("Hello", "I", "love", "python")

1 Answer

Steven Parker
Steven Parker
231,248 Points

To print the result of calling a function, the function must return something. So since these functions print internally but don't return any value, their value will be "None".

Have the function return a value instead of (or in addition to) printing and then you'll see that value as the output.