String concatenation means combining two or more strings together to form a single string. In Python, you can concatenate strings in several ways:
+ operator.f-strings (formatted string literals).format() method.join() to join items from an iterable like a list.str() if you want to combine numbers with text.f-strings and format() help embed variables inside strings cleanly.join() is efficient when combining many strings from a list or other iterable.The simplest way to concatenate strings is with the + operator. You can also add spaces manually where needed.
f-Strings (available from Python 3.6+) are written by prefixing a string with f and placing variables or expressions inside { }. They are very readable and efficient.
The format() method replaces { } placeholders inside a string with provided values in order.
The join() method is called on a separator string (like " ") and takes an iterable of strings (like a list) to combine them into one string.
first = "Hello"
second = "World"
result = first + " " + second
print(result) # Hello World
name = "Alice"
age = 25
message = f"My name is {name} and I am {age} years old."
print(message)
name = "Alice"
age = 25
message = "My name is {} and I am {} years old.".format(name, age)
print(message)
words = ["Python", "is", "awesome"]
sentence = " ".join(words)
print(sentence) # Python is awesome
Hello WorldMy name is Alice and I am 25 years old.My name is Alice and I am 25 years old.Python is awesomeAll four examples build new strings from smaller pieces. Notice how f-strings and format() handle variables neatly without needing explicit + and str() conversions for numbers.
f-strings for readable and efficient concatenation with variables.join() when combining many strings from a list or other iterable.+, for example "Hello " + name.str() or use f-strings: f"Age: {age}"." ".join(...).str() or an f-string.