I have a long string of farmAnimals that looks like this: it has \n\n\n and a \t in front of the Farm Animals
Farm Animals
F
M
Total
Cow
11
10
21
Horse
3
6
9
Sheep
4
8
12
Goat
3
4
7
Chicken
1
1
2
Hen
5
7
12
Pig
3
7
10
Turkey
0
5
5
Cattle
1
1
2
Llama
3
5
8
Donkey
5
9
14
Duck
1
1
2
Total
40
64
104
I want to make the output look like this:
Farm Animals F M Total
Cow 11 12 23
Horse 5 5 10
Sheep 4 12 16
.......
Total 108 134 242
what I did so far is
print(farmAnimalsString.strip().replace('\n\n','').replace('\t',' ').replace('\n\n\n','').replace('\n\n\n\n',''))
My current solution doesn't necessarily produce the correct output but its close. There are different amounts of \n between each field, which makes it tricky for me. So, I am wondering if there is a better way to do this because all I can think about is this brute force way, and I think by doing this I won't be able to get the output that I want..
Thanks in advance!
Edit: I just realized that one of the animal names are two words such as "Jack Rabbit" So when it printed, it looks like
Farm Animals F M Total Jack
Rabbit 1 2 3 Snow
Bunny 0 1 1 Cow
0 1 1 Total 1
4 5