String 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])
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 7
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 1.64
String Indexing in Python
Sveip for å vise menyen
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])
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 7