Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Negative Indexation | Strings
Tipos de Datos en Python
course content

Contenido del Curso

Tipos de Datos en Python

Tipos de Datos en Python

1. Familiarizándonos con los Números en Python
2. ¿Verdadero o Falso?
3. Strings
4. Reuniendo Todos los Temas

book
Negative Indexation

In the preceding chapter, it appeared that we were counting letters to determine the index corresponding to each letter. If we intend to access the final symbol, manual counting may seem cumbersome.

Python, however, is considerate and anticipates our needs. Consequently, it introduced negative indexing. To obtain the last character of a word, it is advisable to utilize the syntax word[-1].

Note

The negative indexation starts from -1, then -2, etc. word[-0] is the same as word[0] for Python.

A small piece of advice: We can mentally divide a string into two parts and use positive indexation for the left-hand part and negative indexation for the right-hand part, but it's always up to us.😏

Tarea
test

Swipe to begin your solution

Using the string "courage", retrieve the letters a, g, and e by applying negative indexing.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 5
toggle bottom row

book
Negative Indexation

In the preceding chapter, it appeared that we were counting letters to determine the index corresponding to each letter. If we intend to access the final symbol, manual counting may seem cumbersome.

Python, however, is considerate and anticipates our needs. Consequently, it introduced negative indexing. To obtain the last character of a word, it is advisable to utilize the syntax word[-1].

Note

The negative indexation starts from -1, then -2, etc. word[-0] is the same as word[0] for Python.

A small piece of advice: We can mentally divide a string into two parts and use positive indexation for the left-hand part and negative indexation for the right-hand part, but it's always up to us.😏

Tarea
test

Swipe to begin your solution

Using the string "courage", retrieve the letters a, g, and e by applying negative indexing.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 5
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt