🐍
Python Extra
  • Python: An Introduction
  • Python Getting Started
  • Python Syntax and Execution
  • Python Comments
  • Python Variables
  • Python Data Types
  • Python Numbers
  • Python Casting
  • Python Strings
    • Python - Slicing Strings
    • Python - Modify Strings
    • Python - String Concatenation
    • Python - Format Strings
    • Python - Escape Characters
    • Python - String Methods
  • Python Booleans
  • Python Operators
  • Python Lists
Powered by GitBook
On this page
  1. Python Strings

Python - String Concatenation

In Python, you can concatenate, or combine, two strings by using the + operator. This allows you to join strings together to create a single, longer string.

Example

To merge the content of a and b into a new variable c:

a = "Hello"
b = "World"
c = a + b
print(c)  # This will print "HelloWorld"

Adding a Space

If you want to add a space between the two strings, you can include a space within the quotes:

a = "Hello"
b = "World"
c = a + " " + b
print(c)  # This will print "Hello World"

String concatenation is a fundamental operation when working with text data, and it allows you to build more complex strings by combining simpler ones.

PreviousPython - Modify StringsNextPython - Format Strings

Last updated 1 year ago