- 3
WOULD YOU SAY PYTHON RETURN FUCTION IS SIMILOAR TO THE POP() FUNCTION ?
Pop function and Return function would you say they have similarities. They both can return a value and you can store the value in a variable? Keyword: SIMILARTIES ! both can return a value only difference pop() can remove the value!! Python community do you agree with me??
4 Réponses
+ 6
Oral Napier ,
first of all, return is not a function. it is a python keyword that can be used to give back (return) values to the caller. return can only be used from inside named functions. this can be a user defined function or a python builtin function or a function from libraries (modules).
however, a function does not necessarily have to return anything.
the list method pop() can be used to remove a desired element from a list, and uses return to provide the removed element to the user.
from this explanations you can see that *return* is NOT similar to the *pop()* method.
+ 1
Ok thank you I understand now
0
No, Pop Remove an Item and Return It. Return function only returns the value
0
I know pop remove and item but pop has a similarly to return function where it can return the value so it has it difference of removing it and also return it.