You could just slice the list:
mainlist = [5,4,3,2,1]
n = 3
mainlist, mylist= a[:n], a[n:]
Keep in mind that for slicing, the first index is inclusive, while the second is exclusive, so mainlist wouldn’t contain index 3 but mylist would.
4
solved In Python how do you pop the first n elements of a list and append these to a new list? [closed]