belongs to collection: Python List Exercises
list1 = ["Mike", "", "Emma", "Kelly", "", "Brad"]
Expected output:
["Mike", "Emma", "Kelly", "Brad"]
Hint:
Use a filter() function to remove the None / empty type from the list
filter()
None
Solution:
Use a filter() function to remove None type from the list
list1 = ["Mike", "", "Emma", "Kelly", "", "Brad"] # remove None from list1 and convert result into list res = list(filter(None, list1)) print(res)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use a
filter()
function to remove theNone
/ empty type from the listSolution:
Use a
need an explanation for this answer? contact us directly to get an explanation for this answerfilter()
function to removeNone
type from the list