I'm new to python and I'm currently styding it, more specifically how to create functions; in this piece of code, I'm supposed to create a function that concatenates all of the arguments given in a single sentence.
def concatenate_all(**kwargs):
"""Gets any number of strings and concatenate them all in a single sentence, separating them with spaces"""
concat_str = ""
for string in kwargs.items():
concat_str = concat_str + kwargs.keys(string)
return concat_str
This tests if my function is working as requested or not by showing True or False
print(concatenate_all("I", "did", "it") == "I did it ")
print(concatenate_all("I", "did", "it", "again", "!!!") == "I did it again !!! ")
and I'm getting this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-40-cd1682a7625a> in <module>()
6 return concat_str
7
----> 8 print(concatenate_all("I", "did", "it") == "I did it ")
9 print(concatenate_all("I", "did", "it", "again", "!!!") == "I did it again !!! ")
TypeError: concatenate_all() takes 0 positional arguments but 3 were given
I'm not quite sure why... (?????) I mean, the arguments were provided, it's almost as if it's not recognizing the **kwargs attribute... Any thoughts? Thanks in advance! :)