Strings

Strings are used to represent sequences of characters. They are commonly used to store and manipulate textual data such as words, sentences, and sometimes even entire documents. You can enclose a string in single quotes (‘’) or double quotes (“”). For example.

name = “John”

Concatenation

String concatenation is the process of combining or joining two or more strings together to create a single string. In Python, you can concatenate strings using the concatenation operator (+) or by using the str() function.

Lets take a look at an example.

Here, we are concatenating the values of the name and age variables with other strings to form the message string.

name = “John”

age = 25

message = “My name is “ + name + “ and I am “             + ...

Get Python Made Easy now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.