Indexing
Suppose we have a string. Now it's time to learn how we can work with it. First, let's learn how to access certain string characters.
Use square brackets with an index inside to access a particular string element. An index is not a position of a specific element since indexing in Python starts from 0. Take a look at the example below.
As you can see, the index in Python is always 1 less than the position. For example, we can get several letters of the word above.
1234# Initial string site = "codefinity" # Get the letters 'o' and 'y' print(site[1], site[9])
¡Gracias por tus comentarios!
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Pregunte me preguntas sobre este tema
Resumir este capítulo
Mostrar ejemplos del mundo real
Awesome!
Completion rate improved to 4
Indexing
Desliza para mostrar el menú
Suppose we have a string. Now it's time to learn how we can work with it. First, let's learn how to access certain string characters.
Use square brackets with an index inside to access a particular string element. An index is not a position of a specific element since indexing in Python starts from 0. Take a look at the example below.
As you can see, the index in Python is always 1 less than the position. For example, we can get several letters of the word above.
1234# Initial string site = "codefinity" # Get the letters 'o' and 'y' print(site[1], site[9])
¡Gracias por tus comentarios!