String Join Lines in Python
Level 374 keystrokes
This joins a list of strings with newlines. The join() method concatenates strings with the specified separator.
Python code
# Create a list of line strings1lines = ["Line 1", "Line 2", "Line 3"]# "\n".join() joins all strings with newline between them# Result: "Line 1\nLine 2\nLine 3"2text = "\n".join(lines)# Print displays each line on a separate line3print(text)Output
Line 1 Line 2 Line 3
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 8,× 2(× 2)× 2=× 2.× 1[× 1]× 1\× 1