Using a lambda expression here is not very pythonic, but if you must:
sentence = "The quick brown fox jumps over the bridge"
vowels = "aeiouAEIOU"
finalVowel = []
# Return True if arg is in vowels; otherwise, return False
isVowel = lambda arg: arg in vowels
def vowelFilter(sentence):
for letter in sentence:
if isVowel(letter): # Call the lambda to test if letter is a vowel
finalVowel.append(letter)
return finalVowel
print (vowelFilter(sentence))
From the docs:
lambda_expr ::= "lambda" [parameter_list]: expression
old_lambda_expr ::= "lambda" [parameter_list]: old_expression
Lambda expressions (sometimes called lambda forms) have the same syntactic position as expressions. They are a shorthand to create anonymous functions; the expression lambda arguments: expression yields a function object. The unnamed object behaves like a function object defined with
def name(arguments): return expression
See section Function definitions for the syntax of parameter lists. Note that functions created with lambda expressions cannot contain statements.