¿Cómo iterar sobre strings en Python? Ejemplos + ejercicios

Published: 21 July 2020
on channel: Olga Soboleva
349
17

#pythonespañol #replacestrings #funcionreplace #metodoreplace #stingspython

Ejercicios:

1. ¿Cuántos caracteres hay en estos strings?

p = 'disponibilidad'

dub = 'Habia un raton, ton ton muy muy chiquitin, tin tin tan tan chiquitin'

2. ¿Cuantas letras:

d
i
l

hay en el string siguiente?

p = 'disponibilidad'

3. ¿Cuántas fragmentos ton , tin , tan , comas, letras t hay en el string siguiente?

dub = 'Habia un raton, ton ton muy muy chiquitin, tin tin tan tan chiquitin'

Hay que usar un bucle for para responder.

________________________________________________________________________________________

Aprendimos iterar sobre listas en Python, vamos a aprender recorrer strings en Python. Usamos el mismo algoritmo.

Ejemplo de un string:

f = 'kiwi'

Contamos el número de letras en este string, el número de letras 'i' y demostramos el número de índice de cada letra de este string en Python.

También sabemos cuándo hay que reemplazar la variable de iteración por un guión bajo y como aplicar la función len a strings y listas.

Creamos una nueva variable y la nombramos LETTER_TO_CHECK para evitar una situación difícil con la letra 'i'.

Curso №2 de Python en español 10
Curso de programación en Python en español


On this page of the site you can watch the video online ¿Cómo iterar sobre strings en Python? Ejemplos + ejercicios with a duration of hours minute second in good quality, which was uploaded by the user Olga Soboleva 21 July 2020, share the link with friends and acquaintances, this video has already been watched 349 times on youtube and it was liked by 17 viewers. Enjoy your viewing!