solutions

Transform list to tuple

Write a function list_2_tuple that takes a list as a parameter and returns a tuple containing the same elements. Example:

list_2_tuple([1, 'c', 9, False])  # (1, 'c', 9, False)
list_2_tuple([2])                 # (2,)

Test Cases

test with many elements - Run Test

def test_with_many_elements():
    assert list_2_tuple(['a', 3, True, 9]) == ('a', 3, True, 9)

test with one element - Run Test

def test_with_one_element():
    assert list_2_tuple([7]) == (7, )