About List Spreading

In Python, you can build a list dynamically by spreading list components:

1
2
3
4
5
first = get_first_element()
sublist1 = get_sublist1()
sublist2 = get_sublist2()
last = get_last_element()
result = [first, *sublist1, *sublist2, last]

Tips and Tricks Programming Python 3