Oct-21-2020, 07:47 AM
I have a list named data having the items shown as below.
a229f7d1148c27d5ff46cbf506f92a9e
3c73dc22ddaafa58346cc5241a78d509
c5ebe3eff60ef972fdd9a9d5e4762227
1c720ec8c2615529e1500d77020a1dc2
63d8e40d1c5aabbee5cf35a13a95b089
0994bcd4f5722e3ae8620a483b83abbf
06f628503dddc37956e586b9e537b3ae
a229f7d1148c27d5ff46cbf506f92a9e
3c73dc22ddaafa58346cc5241a78d509
f6ebd290be34c47ffc84f0a4f123112a
c5ebe3eff60ef972fdd9a9d5e4762227
1c720ec8c2615529e1500d77020a1dc2
I want to concatenate 2 items at a time for the entire list and copy that to an output file as below:
data[index+ 1] + data[index] so that i get the following items
3c73dc22ddaafa58346cc5241a78d509a229f7d1148c27d5ff46cbf506f92a9e
1c720ec8c2615529e1500d77020a1dc2c5ebe3eff60ef972fdd9a9d5e4762227
and so on till the end of the list.
ind = 0
while ind < len(data):
for i in range(int(len(data)/2)):
new_file.write("".join(data[(ind + 1): ind]))
new_file.write("\n")
ind += 2
But i am not getting the desired output. What am i doing wrong in the while loop?
a229f7d1148c27d5ff46cbf506f92a9e
3c73dc22ddaafa58346cc5241a78d509
c5ebe3eff60ef972fdd9a9d5e4762227
1c720ec8c2615529e1500d77020a1dc2
63d8e40d1c5aabbee5cf35a13a95b089
0994bcd4f5722e3ae8620a483b83abbf
06f628503dddc37956e586b9e537b3ae
a229f7d1148c27d5ff46cbf506f92a9e
3c73dc22ddaafa58346cc5241a78d509
f6ebd290be34c47ffc84f0a4f123112a
c5ebe3eff60ef972fdd9a9d5e4762227
1c720ec8c2615529e1500d77020a1dc2
I want to concatenate 2 items at a time for the entire list and copy that to an output file as below:
data[index+ 1] + data[index] so that i get the following items
3c73dc22ddaafa58346cc5241a78d509a229f7d1148c27d5ff46cbf506f92a9e
1c720ec8c2615529e1500d77020a1dc2c5ebe3eff60ef972fdd9a9d5e4762227
and so on till the end of the list.
ind = 0
while ind < len(data):
for i in range(int(len(data)/2)):
new_file.write("".join(data[(ind + 1): ind]))
new_file.write("\n")
ind += 2
But i am not getting the desired output. What am i doing wrong in the while loop?