Build a Large String Efficiently

Medium ⏱ 12 min 49% acceptance ★★★★★ 4.6
Write build_report_line(values) that takes a list of mixed-type values and returns them joined into a single string separated by " | ", converting every value to its string form first. Prefer str.join() over repeated += concatenation — joining a list is the efficient, idiomatic way to build a string from many pieces.

Examples

Example 1
Input
values = [1, 'Rahul', 4.5]
Output
'1 | Rahul | 4.5'
Explanation

Every element is converted with str() before joining.

Constraints

  • values has at least one element.

Topics

StringsString Building

Companies

UberSwiggy

Hints

Hint 1

Use a generator expression `str(v) for v in values` inside `' | '.join(...)`.

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