How to Append to String in Python ? Last Updated : 06 Dec, 2024 Comments Improve Suggest changes Like Article Like Report In Python, Strings are immutable datatypes. So, appending to a string is nothing but string concatenation which means adding a string at the end of another string.Let us explore how we can append to a String with a simple example in Python. Python s = "Geeks" + "ForGeeks" print(s) OutputGeeksForGeeks Note: In the above example, you might note that there is no space between the two strings. For this, you can either add a space in one of the original strings or append a space as well. Python s1 = "Geeks" s2 = "For" s3 = "Geeks" print(s1 + " " + s2 + " " +s3) OutputGeeks For Geeks Now let us see different ways to append to a String in Python one by one.Table of ContentUsing join() FunctionUsing f-StringUsing format() FunctionUsing __add__() MethodUsing join() Functionjoin() function is also used to concatenate or append two or more strings in Python. It takes an iterable that is a list or a tuple as the parameters and join them in the given order. Python s1 = "Geeks" s2 = "For Geeks" print(" ".join([s1, s2])) OutputGeeks For Geeks Using f-String f-string in Python is used in string formatting. It directly embeds the expression inside the curly braces. Python s1 = "Geeks" s2 = "For Geeks" print(f"{s1} {s2}") OutputGeeks For Geeks Using format() FunctionPython format() function is an inbuilt function used to format strings. Unline f-string, it explicitly takes the expression as arguments. Python s1 = "Geeks" s2 = "For Geeks" print("{} {}".format(s1, s2)) OutputGeeks For Geeks Using __add__() Method__add__() method is a Python inbuilt method that is used to define the behaviour of concatenate operator "+" for objects. In this example, we have explicitly added a space in the start of the second string. Python s1 = "Geeks" s2 = "For Geeks" print(s1.__add__(s2)) OutputGeeksFor Geeks Comment More infoAdvertise with us Next Article How to Append to String in Python ? T tanyasehr88x Follow Improve Article Tags : Python Python Programs python-string Python string-programs Practice Tags : python Similar Reads How to copy a string in Python Creating a copy of a string is useful when we need a duplicate of a string to work with while keeping the original string intact, strings in Python are immutable which means they can't be altered after creation, so creating a copy sometimes becomes a necessity for specific use cases.Using SlicingSli 2 min read Python | Append String to list Sometimes, while working with data, we can have a problem in which we need to add elements to a container. The list can contain any type of data type. Let's discuss certain ways in Python in which we can perform string append operations in the list of integers.Example: Append String at the end of a 5 min read How to Repeat a String in Python? Repeating a string is a simple task in Python. We can create multiple copies of a string by using built-in features. This is useful when we need to repeat a word, phrase, or any other string a specific number of times. Using Multiplication Operator (*):Using Multiplication operator (*) is the simple 2 min read How to Create String Array in Python ? To create a string array in Python, different methods can be used based on the requirement. A list can store multiple strings easily, NumPy arrays offer more features for large-scale data and the array module provides type-restricted storage. Each method helps in managing collections of text values 2 min read How to Remove a Substring in Python? In Python, removing a substring from a string can be achieved through various methods such as using replace() function, slicing, or regular expressions. Depending on your specific use case, you may want to remove all instances of a substring or just the first occurrence. Letâs explore different ways 2 min read Python - Conditional String Append Sometimes, while working with data, we have a problem in which we need to perform an append operation in a string on a particular condition. This kind of problem is common in web development and day-day programming. Let's discuss certain ways in which this task can be performed. Method #1: Using loo 4 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 | Add one string to another The concatenation of two strings has been discussed multiple times in various languages. But the task is how to add to a string in Python or append one string to another in Python. Example Input: 'GFG' + 'is best' Output: 'GFG is best' Explanation: Here we can add two string using "+" operator in Py 5 min read Convert tuple to string in Python The goal is to convert the elements of a tuple into a single string, with each element joined by a specific separator, such as a space or no separator at all. For example, in the tuple ('Learn', 'Python', 'Programming'), we aim to convert it into the string "Learn Python Programming". Let's explore 2 min read How to append None to a list? The None keyword in Python represents the absence of a value or a null value, so it is mostly used to initialize a variable or to signify the end of a function or it acts as a placeholder for future data.Let's see how we can append None to a list in Python.Using append() methodThe append() method is 2 min read Like