Back to Lesson

Stream Trimming Filters

Reduce complex array strings effortlessly.

Instructions

  • Initialize
    words = ["apple", "", "banana", "   ", "cherry"]
    .
  • We must discard invalid characters... specifically components where whitespace maps as empty strings inherently.
  • Leverage
    filter
    incorporating
    lambda w: w.strip() != ""
    limits evaluating properties against items directly.
  • Encapsulate the resulting logic mapping returning
    list(...)
    printing output.
main.py
main.py