Reputation: 489
I know how to combine objects with .append and .extend ect, but I can't figure out all all how to combine individual objects in a list into one object.
Example.
How would I change this list: List = ["h","e","l","l","o"]
Into this list: List = ["hello"]
Upvotes: 0
Views: 3054
Reputation: 1126
That can be easily done with
["".join(list)]
For other uses, you can replace "" with any character that you wish to be the delimeter. For example
my_list = ["these", "should", "be", "separated", "by", "commas"]
print ",".join(my_list)
will output
"these,should,be,separated,by,commas"
Upvotes: 5