Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Slice the Word | Strings
Data Types in Python
course content

Course Content

Data Types in Python

Data Types in Python

1. Getting Familiar With Numbers in Python
2. True or False?
3. Strings
4. Bring All the Topics Together

bookSlice the Word

In the preceding chapter, we discussed the method for extracting a particular character from a string. However, what procedures can we employ to obtain a particular substring with a consecutive sequence of characters? The most straightforward approach is to employ a technique called slicing.

This operation allows us to get not only one symbol, but a combination of symbols per operation. Take a look at the syntax:

123
string = "Extract the word kitten" kitten = string[17:23] print(kitten)
copy

The syntax is string[starting_index : ending_index], but try to double check the indexation for the word kitten.

k has an index of 17, but the n character has an index of 22, not 23.

Why was 23 written?

The solution is straightforward. The ending index is exclusive, meaning that when we write 23, Python does not include this index but considers the one immediately before it.

Task

Proficiency in handling strings is of paramount importance. Furthermore, it will significantly enhance your ability to manipulate data structures.

  1. Select the word puppy using slicing.
  2. Select the word nestling using slicing.
  3. Print the variable puppy.
  4. Print the variable nestling.

Use the features that were examined in this chapter.😇

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 3. Chapter 4
toggle bottom row

bookSlice the Word

In the preceding chapter, we discussed the method for extracting a particular character from a string. However, what procedures can we employ to obtain a particular substring with a consecutive sequence of characters? The most straightforward approach is to employ a technique called slicing.

This operation allows us to get not only one symbol, but a combination of symbols per operation. Take a look at the syntax:

123
string = "Extract the word kitten" kitten = string[17:23] print(kitten)
copy

The syntax is string[starting_index : ending_index], but try to double check the indexation for the word kitten.

k has an index of 17, but the n character has an index of 22, not 23.

Why was 23 written?

The solution is straightforward. The ending index is exclusive, meaning that when we write 23, Python does not include this index but considers the one immediately before it.

Task

Proficiency in handling strings is of paramount importance. Furthermore, it will significantly enhance your ability to manipulate data structures.

  1. Select the word puppy using slicing.
  2. Select the word nestling using slicing.
  3. Print the variable puppy.
  4. Print the variable nestling.

Use the features that were examined in this chapter.😇

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 3. Chapter 4
toggle bottom row

bookSlice the Word

In the preceding chapter, we discussed the method for extracting a particular character from a string. However, what procedures can we employ to obtain a particular substring with a consecutive sequence of characters? The most straightforward approach is to employ a technique called slicing.

This operation allows us to get not only one symbol, but a combination of symbols per operation. Take a look at the syntax:

123
string = "Extract the word kitten" kitten = string[17:23] print(kitten)
copy

The syntax is string[starting_index : ending_index], but try to double check the indexation for the word kitten.

k has an index of 17, but the n character has an index of 22, not 23.

Why was 23 written?

The solution is straightforward. The ending index is exclusive, meaning that when we write 23, Python does not include this index but considers the one immediately before it.

Task

Proficiency in handling strings is of paramount importance. Furthermore, it will significantly enhance your ability to manipulate data structures.

  1. Select the word puppy using slicing.
  2. Select the word nestling using slicing.
  3. Print the variable puppy.
  4. Print the variable nestling.

Use the features that were examined in this chapter.😇

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!

In the preceding chapter, we discussed the method for extracting a particular character from a string. However, what procedures can we employ to obtain a particular substring with a consecutive sequence of characters? The most straightforward approach is to employ a technique called slicing.

This operation allows us to get not only one symbol, but a combination of symbols per operation. Take a look at the syntax:

123
string = "Extract the word kitten" kitten = string[17:23] print(kitten)
copy

The syntax is string[starting_index : ending_index], but try to double check the indexation for the word kitten.

k has an index of 17, but the n character has an index of 22, not 23.

Why was 23 written?

The solution is straightforward. The ending index is exclusive, meaning that when we write 23, Python does not include this index but considers the one immediately before it.

Task

Proficiency in handling strings is of paramount importance. Furthermore, it will significantly enhance your ability to manipulate data structures.

  1. Select the word puppy using slicing.
  2. Select the word nestling using slicing.
  3. Print the variable puppy.
  4. Print the variable nestling.

Use the features that were examined in this chapter.😇

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 4
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt