Clean Up Messy CSV Cells

Medium ⏱ 12 min 57% acceptance ★★★★☆ 4.2
Raw CSV cells arrive with stray whitespace and empty strings. Write clean_cells(cells) that strips each cell and drops the ones that are empty after stripping — one comprehension, order preserved.

Examples

Example 1
Input
clean_cells(['  alice ', '', '  ', 'bob'])
Output
['alice', 'bob']
Explanation

Whitespace-only cells vanish; survivors are stripped.

Constraints

  • Strip before testing emptiness.
  • Single comprehension.

Topics

List Comprehensionsstring cleanup

Companies

DeloitteCapgeminiIBM

Hints

Hint 1

A stripped empty string is falsy.

Hint 2

You may call .strip() twice, or use the walrus operator to strip once.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.