Python - Line Break in String Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Line Break helps in making the string easier to read or display in a specific format. When working with lists, the join() method is useful, and formatted strings give us more control over our output.Using \n for new line The simplest way to add a line break in a string is by using the special character( \n). This character tells Python to break the string at that point and start a new line. Python a = "Hello\nWorld" print(a) OutputHello World Let's look into other methods that use to break line in Python. Table of ContentUsing Triple Quotes for Multiline StringsUsing String Join with a ListUsing Format StringsUsing Triple Quotes for Multiline StringsAnother easy method to create multiline strings is by using triple quotes. This allows us to write the string across multiple lines directly. Python b = """Hello World""" print(b) OutputHello World Using String Join with a ListSometimes we have a list of strings and want to join them with a line break in between. We can do this using the join() method. Python c = ["Hello", "World"] d = "\n".join(c) print(d) OutputHello World Using Format StringsIf we need more control over how the line breaks appear, we can use formatted strings with f-strings. Python e = "Hello" f = "World" g = f"{e}\n{f}" print(g) OutputHello World Comment More infoAdvertise with us Next Article Python - Add Phrase in middle of String P pragya22r4 Follow Improve Article Tags : Python Python Programs python-string Python string-programs Practice Tags : python Similar Reads Split and join a string in Python The goal here is to split a string into smaller parts based on a delimiter and then join those parts back together with a different delimiter. For example, given the string "Hello, how are you?", you might want to split it by spaces to get a list of individual words and then join them back together 3 min read How to Initialize a String in Python In Python, initializing a string variable is straightforward and can be done in several ways. Strings in Python are immutable sequences of characters enclosed in either single quotes, double quotes or triple quotes. Letâs explore how to efficiently initialize string variables.Using Single or Double 2 min read Python - Words Lengths in String We are given a string we need to find length of each word in a given string. For example, we are s = "Hello world this is Python" we need to find length of each word so that output should be a list containing length of each words in sentence, so output in this case will be [5, 5, 4, 2, 6].Using List 2 min read Python - Add Phrase in middle of String Given a String, add a phrase in the middle of it. Input : test_str = 'geekforgeeks is for geeks', mid_str = "good" Output : geekforgeeks is good for geeks Explanation : Added just in middle, after 2 words. Input : test_str = 'geekforgeeks best', mid_str = "is" Output : geekforgeeks is best Explanati 7 min read Python - Add Phrase in middle of String Given a String, add a phrase in the middle of it. Input : test_str = 'geekforgeeks is for geeks', mid_str = "good" Output : geekforgeeks is good for geeks Explanation : Added just in middle, after 2 words. Input : test_str = 'geekforgeeks best', mid_str = "is" Output : geekforgeeks is best Explanati 7 min read Insert a Variable into a String - Python The goal here is to insert a variable into a string in Python. For example, if we have a variable containing the word "Hello" and another containing "World", we want to combine them into a single string like "Hello World". Let's explore the different methods to insert variables into strings effectiv 2 min read Like