separator = ' and ' # String to separate sequence items by. words = ['this', 'that'] # String to join. joined = separator.join(words) # Join items in sequence words, # separated by 'separator'. print(joined) polyhedra = ["cube", "dodecahedron", "icosahedron"] # The .join() method is often called on a string literal, without assigning it # to a variable first. joined = ", ".join(polyhedra) print(joined) # Prints "cube, dodecahedron, icosahedron"
|Description||Combines a sequence of strings to create a new string, separating each item from the sequence with the content of the string the method is called on.|