Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Write a function that modifies a passed list

Practice modifying a list passed into a function (in-place) and returning the updated list.

Python practice8 minFunctions & ScopeBeginnerLast updated March 17, 2026

Problem statement

Write a function named append_value(lst, value) that takes a list lst and a value value, appends value to lst (modifying the original list), and returns the same list object with the new element added. Do not create and return a new list — modify the provided list in place.

Task

Implement a function that appends a value to a list argument, modifying it in-place and returning the modified list.

Examples

Append an integer

Input

append_value([1, 2], 3)

Output

[1, 2, 3]

The function appends 3 to the provided list and returns the list with the new element.

Input format

A list (lst) and a single value (value) to append.

Output format

Return the same list with the new value appended (the printed representation of the list).

Constraints

Do not create a new list; modify lst in place and return it. The list can contain elements of any type.

Samples

Sample 1

Input

append_value(['a'], 'b')

Output

['a', 'b']

The value 'b' is appended to the existing list.