Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära String Indexing in Python | Variables and Types in Python
Introduction to Python (dev copy)

bookString Indexing in Python

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.

12345
# Initial string site = "codefinity" # Get the letters 'o' and 'y' print(site[1], site[9])
copy
question mark

Imagine you're given the string test. Identify the character that corresponds to the index 6.

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 7

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Ställ mig frågor om detta ämne

Sammanfatta detta kapitel

Visa verkliga exempel

Awesome!

Completion rate improved to 1.64

bookString Indexing in Python

Svep för att visa menyn

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.

12345
# Initial string site = "codefinity" # Get the letters 'o' and 'y' print(site[1], site[9])
copy
question mark

Imagine you're given the string test. Identify the character that corresponds to the index 6.

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 7
some-alt