Update exercises 18

Signed-off-by: Manuel Vergara <manuel@vergaracarmona.es>
This commit is contained in:
Manuel Vergara 2023-09-30 22:26:15 +02:00
parent f391b1b42a
commit 7f6426e0ee
2 changed files with 26 additions and 0 deletions

View File

@ -108,3 +108,17 @@ for word in words:
most_freq_words = sorted(word_freq, key=word_freq.get, reverse=True)[:3] most_freq_words = sorted(word_freq, key=word_freq.get, reverse=True)[:3]
print("Las tres palabras más frecuentes son:", most_freq_words) print("Las tres palabras más frecuentes son:", most_freq_words)
# Ejercicios: Nivel 4
# 1. Extrae el DNI de la siguiente cadena.
dni = """Asunto: Datos para la nómina.
Respondiendo a su mail, le paso el dato personal que le faltaba. Mi DNI es 12345678A.
Saludos.
"""
# Extraemos el DNI
dni = re.search(r'\d{8}[A-Z]', dni).group()
print("DNI:", dni)

View File

@ -69,6 +69,18 @@ print(clean_text(sentence));
I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher
print(most_frequent_words(cleaned_text)) # [(3, 'I'), (2, 'teaching'), (2, 'teacher')] print(most_frequent_words(cleaned_text)) # [(3, 'I'), (2, 'teaching'), (2, 'teacher')]
``` ```
### Ejercicios: Nivel 4
1. Extrae el DNI de la siguiente cadena.
```
dni = """Asunto: Datos para la nómina.
Respondiendo a su mail, le paso el dato personal que le faltaba. Mi DNI es 12345678A.
Saludos.
"""
```
[Solución](01_regex.py) [Solución](01_regex.py)
[<< Day 17](../17_Manejo_de_excepciones/README.md) | [Day 19 >>](../19_Manipulación_de_archivos/README.md) [<< Day 17](../17_Manejo_de_excepciones/README.md) | [Day 19 >>](../19_Manipulación_de_archivos/README.md)