Home > Enterprise >  Find and return the list of words that contain letters as SUBSEQUENCE
Find and return the list of words that contain letters as SUBSEQUENCE

Time:10-24

QuestionHere

def words_with_letters(words, letters):
  
  return [word for word in words if all(letter in word for letter in letters)]

the above code does not work and have tried to figure out why the system does not consider this. Please click the "QuestionHere" link to understand

CodePudding user response:

def words_with_letters(words, letters):

   return [word for word in words if word.endswith(letters)]
print(words_with_letters(['aakk','bbkk','ccc'],'kk'))

CodePudding user response:

def words_with_letters(words, letters):
  
  return [word for word in words if letters in word)]
  • Related