Skip to content

[Pati] labs of handling errors#23

Open
patriciazapatab wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
patriciazapatab:main
Open

[Pati] labs of handling errors#23
patriciazapatab wants to merge 1 commit intoIronhack-data-bcn-oct-2023:mainfrom
patriciazapatab:main

Conversation

@patriciazapatab
Copy link
Copy Markdown

b92c75e79c409751997241f1a8dbedb7

saved him

@bripollc
Copy link
Copy Markdown

Hello Pati:)

YESSSSSS! Buen lab e hiciste el bonus, increíble:) well dooooooone. Te dejo un par de cosillas sin importancia.

  • Remove all of the vowels in a string. Hint: make a list of the non-vowels. Use non_vowels as the name of the list.
vowels = "aeiouAEIOU"
non_vowels = [i for i in teststring if i not in vowels and i != ' ']
print (non_vowels)

Correctísima tu respuesta! Solo te dejo un pequeño tip para simplificar el código:) Si añades and i != ' ', eliminarás los espacios de la lista de golpe y en tu comprehension list sin necesidad de crear la lista no_vowels_string y estarás devolviendo una lista. Haciendo "".join estas devolviendo una string.

  • Find all the consonants in the sentence 'The quick brown fox jumped over the lazy dog'.

Aquí si has añadido i != " "! Por lo que no sería necesaria esta parte del código para que te de el resultado 🙃

consonants_string = "".join(str(element) for element in consonants)
print (consonants_string)
  • Handle at least two kind of different exceptions when dividing a couple of numbers provided by the user.
try:
    a = int(input("Enter first number: "))
    b = int(input("Enter second number: "))
    c = a/b
    print(f'Division of {a}/{b} = {c}')
except ValueError:
    print(f'Input should be an int')
except ZeroDivisionError:
    print(f'(You are trying to divide by 0)')

Tu respuesta es super válida pero puedes simplificarlo de esta manera para ahorrarte un try:))))))

A por el siguiente laaaaaab! 💥🙌🏼🚀

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants