'python store a split list into multiple files and items in same line

I have a huge list with 9000 items. I already referred this post here and here. Don't mark it as duplicate

Mylist = [1234,45678,2314,65474,412,87986,21321,4324,68768,1133,712421,12132,0898]

I would like to split my list and store the output of each list in a notepad file

For ex: I wish each of my output list to contain ~10% of items from the original Mylist

So, I tried the below

for k,g in itertools.groupby(Mylist, lambda x: x/10):
      with open("part1.txt", 'w') as file:
      file.write('\n'.join(yourList))

I expect my output to have multiple text files like below and each file should contain 10% of items stored like below in screenshot from original list

part1.txt
part2.txt
part3.txt
part4.txt

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source