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

Зміст курсу

Python Data Types

Python Data Types

1. Numeric Types
2. Boolean Type
3. Strings

Negative Indexing

12345678910
# Creating a string string = 'codefinity' print("Initial string: ", string) string_1 = string[:-7] print("Elements till 7th element from last: ", string_1) string_2 = string[-7:-4] print("Elements from index -7 to -5:",string_2) string_3 = string[::-1] print("String in reverse order: ", string_3)
copy

Завдання

You have such a string programming. You have to carry out these steps:

  1. print elements sliced till 8th element from last(as a result you have to get: pro)
  2. print elements sliced from index -8 to -3(as a result you have to get: grammi)
  3. print elements in reverse using slice operation(as a result you have to get: gnimmargorp).

Завдання

You have such a string programming. You have to carry out these steps:

  1. print elements sliced till 8th element from last(as a result you have to get: pro)
  2. print elements sliced from index -8 to -3(as a result you have to get: grammi)
  3. print elements in reverse using slice operation(as a result you have to get: gnimmargorp).

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

Все було зрозуміло?

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

Negative Indexing

12345678910
# Creating a string string = 'codefinity' print("Initial string: ", string) string_1 = string[:-7] print("Elements till 7th element from last: ", string_1) string_2 = string[-7:-4] print("Elements from index -7 to -5:",string_2) string_3 = string[::-1] print("String in reverse order: ", string_3)
copy

Завдання

You have such a string programming. You have to carry out these steps:

  1. print elements sliced till 8th element from last(as a result you have to get: pro)
  2. print elements sliced from index -8 to -3(as a result you have to get: grammi)
  3. print elements in reverse using slice operation(as a result you have to get: gnimmargorp).

Завдання

You have such a string programming. You have to carry out these steps:

  1. print elements sliced till 8th element from last(as a result you have to get: pro)
  2. print elements sliced from index -8 to -3(as a result you have to get: grammi)
  3. print elements in reverse using slice operation(as a result you have to get: gnimmargorp).

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

Все було зрозуміло?

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

Negative Indexing

12345678910
# Creating a string string = 'codefinity' print("Initial string: ", string) string_1 = string[:-7] print("Elements till 7th element from last: ", string_1) string_2 = string[-7:-4] print("Elements from index -7 to -5:",string_2) string_3 = string[::-1] print("String in reverse order: ", string_3)
copy

Завдання

You have such a string programming. You have to carry out these steps:

  1. print elements sliced till 8th element from last(as a result you have to get: pro)
  2. print elements sliced from index -8 to -3(as a result you have to get: grammi)
  3. print elements in reverse using slice operation(as a result you have to get: gnimmargorp).

Завдання

You have such a string programming. You have to carry out these steps:

  1. print elements sliced till 8th element from last(as a result you have to get: pro)
  2. print elements sliced from index -8 to -3(as a result you have to get: grammi)
  3. print elements in reverse using slice operation(as a result you have to get: gnimmargorp).

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

Все було зрозуміло?

12345678910
# Creating a string string = 'codefinity' print("Initial string: ", string) string_1 = string[:-7] print("Elements till 7th element from last: ", string_1) string_2 = string[-7:-4] print("Elements from index -7 to -5:",string_2) string_3 = string[::-1] print("String in reverse order: ", string_3)
copy

Завдання

You have such a string programming. You have to carry out these steps:

  1. print elements sliced till 8th element from last(as a result you have to get: pro)
  2. print elements sliced from index -8 to -3(as a result you have to get: grammi)
  3. print elements in reverse using slice operation(as a result you have to get: gnimmargorp).

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