Basically, you iterate over the list and see if the current element is a list itself. If it's not, add it to a new list. If it is, iterate over the list and repeat.
It's not the nicest, smallest or most python-way but this way might help you to understand it:
list_in = [1,2,[3,4],5,[6,7,[8,9,10]]]
new_list = []
def unfold_list(l):
for x in l:
if isinstance(x, list):
unfold_list(x)
else:
new_list.append(x)
unfold_list(list_in)
print(new_list)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Note regarding Barmar's comment on Sujay's answer: Using globals should indeed be avoided. My code above is purely meant to help understand the issue and (one of the) solution(s).