Reputation: 55
How can I properly use this operator to concatenate two strings?
string = "Hello"
a = " ".join(string, "World")
print(a)
Output ~ TypeError: join() takes exactly one argument (2 given)
Upvotes: 1
Views: 65
Reputation: 81
The argument to join is basically an iterable, so you just need to put your strings as a list
You can do something like:
" ".join([string," World"])
Upvotes: 2
Reputation: 1653
You should call join on a list of strings.
string = "Hello"
a = " ".join([string, "World"])
print(a)
Upvotes: 1