Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Accessing String Elements | Basic Concepts
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
String Manipulation in Python

bookAccessing String Elements

Now we know how we can create a string: both single and multiline. Now we need to learn how can we access certain elements in the string.

Elements in a string can be accessed by using indices. The very first index is 0, not 1. Therefore, if a string has 10 elements, the very last index will be 9.

Opgave

Swipe to start coding

Given variable course with the string String Manipulation in Python. Your tasks are:

  1. Extract the element with index 7.
  2. Extract the 12th element.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Opsummér dette kapitel

Explain code

Explain why doesn't solve task

close

bookAccessing String Elements

Stryg for at vise menuen

Now we know how we can create a string: both single and multiline. Now we need to learn how can we access certain elements in the string.

Elements in a string can be accessed by using indices. The very first index is 0, not 1. Therefore, if a string has 10 elements, the very last index will be 9.

Opgave

Swipe to start coding

Given variable course with the string String Manipulation in Python. Your tasks are:

  1. Extract the element with index 7.
  2. Extract the 12th element.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3
single

single

some-alt