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.|
Updated on Mon Sep 21 15:53:25 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License