Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Implement argument unpacking with *args and **kwargs

Practice using *args and **kwargs to accept variable positional and keyword arguments, then unpack and use them.

Python practice16 minFunctions & ScopeIntermediateLast updated March 17, 2026

Problem statement

Write a function join_with_options(separator, *items, **options). - separator: a string used to join the items. - items: any number of positional values to be joined (convert to strings if needed). - options: may contain optional keys: - prefix: a string to prepend (default: empty string) - suffix: a string to append (default: empty string) - uppercase: boolean; if True, the joined core string should be converted to uppercase (default: False) Return the final formatted string. This exercise practices receiving arbitrary args/kwargs and unpacking/using them safely.

Task

Implement join_with_options(separator, *items, **options) that joins arbitrary items into a string using a separator and optional keyword options like prefix, suffix, and uppercase.

Examples

Join with prefix and suffix

Input

join_with_options('-', 'a', 'b', prefix='X', suffix='Z')

Output

Xa-bZ

Items 'a' and 'b' are joined with '-', then prefixed with 'X' and suffixed with 'Z'.

Uppercasing

Input

join_with_options(' ', 'hello', 'world', uppercase=True)

Output

HELLO WORLD

The joined core string 'hello world' is converted to uppercase because uppercase=True.

Input format

Call join_with_options with a separator, positional items, and optional keyword arguments like prefix, suffix, and uppercase.

Output format

Return a single formatted string produced by joining items and applying options.

Constraints

- Convert all items to strings before joining. - options may or may not include prefix, suffix, uppercase. - Do not assume the types of items (use str()).

Samples

Sample 1

Input

join_with_options(',', prefix='start', suffix='end')

Output

startend

No items provided, so join yields an empty string and prefix/suffix are concatenated.