Sorry for such a silly question, but sitting in front of the comp for many hours makes my head overheated, in other words — I'm totally confused. My task is to define a function that takes a list of words and returns something. How can I define a function that will take a list of words?
def function(list_of_words):
do something
When running this script in Python IDLE we should suppose to write something like this:
>>> def function('this', 'is', 'a', 'list', 'of', 'words')
But Python errors that the function takes one argument, and six (arguments) are given.
I guess I should give my list a variable name, i.e. list_of_words = ['this', 'is', 'a', 'list', 'of', 'words'], but ... how?
Use code:
def function(*list_of_words):
do something
list_of_words will be a tuple of arguments passed to a function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With