Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Slice the Phrase | Рядки
Типи даних у Python
course content

Зміст курсу

Типи даних у Python

Типи даних у Python

1. Знайомство з числами в Python
2. Істина чи брехня?
3. Рядки
4. Поєднання всіх тем разом

book
Slice the Phrase

If we are certain that we intend to extract all characters from position 5 to the end of the string, there is no need to employ the string[5 : ending_index] syntax. Python offers a diverse array of built-in functions, and it adjusts its syntax to suit your specific needs.
Let’s look at this phrase:

1234
string = "Push beyond your limits" phrase = string[5:] print(phrase)
copy

Alternatively, this also applies when you require the extraction of a phrase starting from the initial point up to a specified index:

123
string = "Push beyond your limits" phrase = string[:11] print(phrase)
copy
Завдання
test

Swipe to begin your solution

Now it's your turn! Follow these steps:

  1. Use slicing to extract the phrase "Get a foot" from the first string and assign it to the variable phrase1.

  2. Use slicing to extract the phrase "away" from the second string and assign it to the variable phrase2 (using negative indexing is recommended here).

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 6
toggle bottom row

book
Slice the Phrase

If we are certain that we intend to extract all characters from position 5 to the end of the string, there is no need to employ the string[5 : ending_index] syntax. Python offers a diverse array of built-in functions, and it adjusts its syntax to suit your specific needs.
Let’s look at this phrase:

1234
string = "Push beyond your limits" phrase = string[5:] print(phrase)
copy

Alternatively, this also applies when you require the extraction of a phrase starting from the initial point up to a specified index:

123
string = "Push beyond your limits" phrase = string[:11] print(phrase)
copy
Завдання
test

Swipe to begin your solution

Now it's your turn! Follow these steps:

  1. Use slicing to extract the phrase "Get a foot" from the first string and assign it to the variable phrase1.

  2. Use slicing to extract the phrase "away" from the second string and assign it to the variable phrase2 (using negative indexing is recommended here).

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 6
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt