Does return print values to the screen?


#1

Question

Does return print values to the screen?

Answer

No, return simply gives a value to wherever it was called in the program. In this exercise, we see that our function list_function() just takes a parameter x and returns it. print looks for a value after it to display it to the screen, and the value it gets is the value returned by the list_function() when we pass it a list, n!
Anytime you want something to be printed, you need to use the print function.


FAQ: Learn Python - Lists and Functions - Passing a list to a function