Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
String Indexing | Variables and Types
Introduction to Python

String IndexingString Indexing

Suppose we have a string. Let's delve into how to work with it. First up, let's understand how to access specific characters within a string.

To access a specific character in a string, use square brackets with an index number inside. Remember, the index number is not the actual position of the character because indexing in Python starts at 0. Consider the example below for clarity.

Image

In Python, the index is always one less than the actual position. For instance, we can retrieve several letters from the word in the example above.

Let's say you're given the string test (as shown below). Identify the character that corresponds to the index 6.

Виберіть правильну відповідь

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

Секція 2. Розділ 8
course content

Зміст курсу

Introduction to Python

String IndexingString Indexing

Suppose we have a string. Let's delve into how to work with it. First up, let's understand how to access specific characters within a string.

To access a specific character in a string, use square brackets with an index number inside. Remember, the index number is not the actual position of the character because indexing in Python starts at 0. Consider the example below for clarity.

Image

In Python, the index is always one less than the actual position. For instance, we can retrieve several letters from the word in the example above.

Let's say you're given the string test (as shown below). Identify the character that corresponds to the index 6.

Виберіть правильну відповідь

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

Секція 2. Розділ 8
some-alt