Skip to content

kata 4 bucle for #306

Answered by JavierMendez-Coder
larap03 asked this question in Q&A
Feb 18, 2022 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Buenas noches.
Tu problema surge de que tu arreglo de palabras clave es una sola cadena en vez de varias palabras. Deja me explico:

# Así lo tienes:
key_word = ["average, temperature, distance"]

# Así debería de ser:
key_word = ["average", "temperature", "distance"] # <-- Observa que cada palabra se encuentra entre comillas (").

Además, estas repitiendo el nombre de la variable con la que recorres el arreglo:

key_word = ["average", "temperature", "distance"]

for sentence in text:
  for key_word in key_word: # <-- Aquí 
    if key_word in sentence:
      print(sentence)
      break

Y debería ser algo así:

key_words = ["average", "temperature", "distance"] # <-- Observa que cambié ligeram…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@larap03
Comment options

@JavierMendez-Coder
Comment options

Answer selected by larap03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants