Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Strings Concatenation | Basic Concepts
String Manipulation in Python
course content

Course Content

String Manipulation in Python

String Manipulation in Python

1. Basic Concepts
2. String Methods
3. Strings Formatting

bookStrings Concatenation

What if we need to connect two strings? Like, we have a price as a number in price variable, and we want to make it representatively, i.e. we want to show the price in format n $. This problem can be solved by concatenation.

Concatenation is joining two strings, which can be done in Python by using a simple + operator. It will join the string on the left side of the operator to the string on the right side. For example,

12
price = 25 print('Price is', str(price) + '$')
copy

As we can see, + operator added the '$' sign to the price converted into a string.

Note

All the space characters are considered by + operator. For example, if in the example above we wrote str(price) + ' $' it would output Price is 25 $.

Task
test

Swipe to show code editor

Given variables height and weight. Using concatenation, output the following messages:

Height: 170 cm

Weight: 70 kg

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 8
toggle bottom row

bookStrings Concatenation

What if we need to connect two strings? Like, we have a price as a number in price variable, and we want to make it representatively, i.e. we want to show the price in format n $. This problem can be solved by concatenation.

Concatenation is joining two strings, which can be done in Python by using a simple + operator. It will join the string on the left side of the operator to the string on the right side. For example,

12
price = 25 print('Price is', str(price) + '$')
copy

As we can see, + operator added the '$' sign to the price converted into a string.

Note

All the space characters are considered by + operator. For example, if in the example above we wrote str(price) + ' $' it would output Price is 25 $.

Task
test

Swipe to show code editor

Given variables height and weight. Using concatenation, output the following messages:

Height: 170 cm

Weight: 70 kg

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 8
toggle bottom row

bookStrings Concatenation

What if we need to connect two strings? Like, we have a price as a number in price variable, and we want to make it representatively, i.e. we want to show the price in format n $. This problem can be solved by concatenation.

Concatenation is joining two strings, which can be done in Python by using a simple + operator. It will join the string on the left side of the operator to the string on the right side. For example,

12
price = 25 print('Price is', str(price) + '$')
copy

As we can see, + operator added the '$' sign to the price converted into a string.

Note

All the space characters are considered by + operator. For example, if in the example above we wrote str(price) + ' $' it would output Price is 25 $.

Task
test

Swipe to show code editor

Given variables height and weight. Using concatenation, output the following messages:

Height: 170 cm

Weight: 70 kg

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

What if we need to connect two strings? Like, we have a price as a number in price variable, and we want to make it representatively, i.e. we want to show the price in format n $. This problem can be solved by concatenation.

Concatenation is joining two strings, which can be done in Python by using a simple + operator. It will join the string on the left side of the operator to the string on the right side. For example,

12
price = 25 print('Price is', str(price) + '$')
copy

As we can see, + operator added the '$' sign to the price converted into a string.

Note

All the space characters are considered by + operator. For example, if in the example above we wrote str(price) + ' $' it would output Price is 25 $.

Task
test

Swipe to show code editor

Given variables height and weight. Using concatenation, output the following messages:

Height: 170 cm

Weight: 70 kg

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 8
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt