Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Map, filter, and join strings into CSV

Clean a list of mixed values using map and filter, then join them into a CSV string.

Python practice13 minFunctions as Objects (Lambda, Map/Filter)IntermediateLast updated March 20, 2026

Problem statement

Write a function make_csv(items) that takes a list of values and returns a single CSV string. The function should: 1) convert each item to a string, 2) strip surrounding whitespace, 3) discard values that become empty after stripping or are None, 4) convert remaining strings to lowercase, and 5) join them with commas. Use map, filter, and join (and lambda where appropriate).

Task

Use map and filter with lambda to normalize values, remove empty entries, and join into a comma-separated string.

Examples

Basic cleanup

Input

make_csv([' Apple ', 'Banana', '', None, 'Cherry'])

Output

apple,banana,cherry

Whitespace trimmed, empty and None removed, and values lowercased then joined.

Input format

A Python list of values (strings, numbers, booleans, or None).

Output format

A single string containing comma-separated cleaned values, or an empty string if nothing remains.

Constraints

Do not use loops explicitly; prefer map and filter with lambdas. The function must handle non-string values by converting them using str().

Samples

Sample 1

Input

make_csv([' a ',' B '])

Output

a,b

Both values trimmed and lowercased, then joined.