a=[str(i) for i in range(88888,88912)] b=[str(i) for i in range(77777,77785)] def f(a,b,k=0,m=0): n=0 g = [] while n<4: j = 0 for i in a[k:]: while j < 1: g.append(i) k = k + 1 j=j+1 break j=0 for i in b[m:]: while j < 2: g.append(i) m = m + 1 j=j+1 break j=0 for i in a[k:]: while j < 5: g.append(i) k = k + 1 j=j+1 break n=n+1 return g if __name__=='__main__': g=f(a,b,0,0) print(g)