python-tutorial icon indicating copy to clipboard operation
python-tutorial copied to clipboard

Issue with exercise "Randomize list" in Functions Advanced

Open Bothkevin opened this issue 8 months ago • 0 comments

Describe the bug The test tries to compare two randomized lists, and passes if they are the same.

Even with the proposed solution, the test does not pass 2/2

To Reproduce Use the proposed solution, and run the cell:

`def solution_randomize_list(my_list: list[int]) -> list[int]: """ A function that randomizes the order of the elements in a list.

Args:
    my_list: A list of integers
Returns:
    - A new list with the elements of `my_list` in random order
"""
return sorted(my_list, key=lambda x: random.random())`

Expected behavior The test should pass with 2/2 green. However, since it compares random lists with each other, the passing rate is also random.

Bothkevin avatar May 09 '25 08:05 Bothkevin