Sorry for wording of the question.
I am reading a file and after some operation I am adding that line to a list. I want to read 100 lines, append it to list then send it and repeat the process.
I've been doing line_count % 100 == 0
then send my list however final 34 lines of code will not get sent, how can I achieve this?
Minimal code to reproduce:
lst = [1,2,3,4,5,6,7,8,9,10,11]
line_count = 0
final_lst = []
for line in lst:
line_count += 1
final_lst.append(line)
if line_count % 2 == 0:
print(f"succesfully sent:{final_lst}")
output:
succesfully sent:[1, 2]
succesfully sent:[1, 2, 3, 4]
succesfully sent:[1, 2, 3, 4, 5, 6]
succesfully sent:[1, 2, 3, 4, 5, 6, 7, 8]
succesfully sent:[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
if you print, it will succesfully send up to [1,2,3,....,10]