I have a list (list.txt) which consists of names like so: James Heather Daniel Peter
The list goes on up to 100 people, my goal is to number the first 3 (x) '1.' the next 3 (x) '2.' and so on.
I have managed to number each person but the number increases as expected with no repetition.
Preferably I want to print the list into Groups.txt to keep the original list untouched so I can later change the size (k) of the groups.
I have tried to somehow implement the following codes into the below:
res = list(itertools.chain.from_iterable(itertools.repeat(y, 3) for y in c))
or
res = [ele for ele in c for i in range(k)]
But it did not work.
f = open('list.txt', 'w')
c = open('Groups.txt')
x = 3
for index, value in enumerate(c, 1):
f.write("{}.{}".format(index, value))
f.close()
Here again what I wish to have as an output: 1.James
1.Heather
1.Daniel
1.Peter
2.Frank
2.Sam
2.Jeff
...etc