I'm currently practicing how to use the zip() function to do clean print outs etc.
It works kind of good, but still, I'm getting these weird unintended indentations in my out-prints.
My code goes like this:
data_list1 = [[7.2, 8.1, 8.9, 11.6, 7.7, 8.7, 6.9], [5.4, 8.8, 8.9, 3.7, 3.3, 5.2, 9.6], [10.8, 5.0, 5.4, 9.5, 5.3, 5.8, 2.3], [4.1, 6.6, 8.2, 6.1, 8.9, 6.6, 4.1], [2.8, 2.1, 4.1]]
data_list2 = [[9.8, 11.6, 11.5, 13.3, 12.6, 10.3, 7.5], [9.3, 10.3, 10.3, 8.4, 8.8, 5.0, 5.8], [6.8, 2.3, 3.5, 7.9, 11.8, 10.7, 9.0], [5.8, 6.8, 11.7, 10.6, 11.7, 13.1, 13.6], [8.0, 3.5, 3.2]]
def clean_up(list1, list2):
data_list1 = []
for i in list1:
for j in i:
data_list1.append(j)
data_list2 = []
for i in list2:
for j in i:
data_list2.append(j)
for data_list1, data_list2 in zip(data_list1, data_list2):
print(f"{data_list1}\t\t\t{data_list2}")
print(clean_up(data_list1,data_list2))
And my out-print is:
7.2 9.8
8.1 11.6
8.9 11.5
11.6 13.3
7.7 12.6
8.7 10.3
6.9 7.5
5.4 9.3
8.8 10.3
8.9 10.3
3.7 8.4
3.3 8.8
5.2 5.0
9.6 5.8
10.8 6.8
5.0 2.3
5.4 3.5
9.5 7.9
5.3 11.8
5.8 10.7
2.3 9.0
4.1 5.8
6.6 6.8
8.2 11.7
6.1 10.6
8.9 11.7
6.6 13.1
4.1 13.6
2.8 8.0
2.1 3.5
4.1 3.2
As you might see, there are a few spots where the out-print look's kind of strange.
My two questions are:
- Is there anyone who has some tips on how to fix this?
- If so, would this technique also make a similar look if I write the data onto a file as well?
All help is welcomed.