0
Python Survey data practical
I seriously need help here Given a list of string representing user answers, write a program that uses the filter() function and lambda expression to create a new list that excludes any empty strings. then display the new cleaned list of answers.
3 Respuestas
+ 3
Would you provide the input and your code attempted?
+ 1
I just came here looking for help on this one but with a bit of tinkering I got mine working.
Here is my answer.
user_answers = ["Yes", "", "No", "", "Maybe", "", "Yes"]
# Create a new list without empty answers
# using filter with a lambda expression
filtered_answers = list(filter(lambda name: name != "", user_answers))
# Display the cleaned list of answers
print(filtered_answers)