I am trying to get the output of my code formatted in the following way:
Expected:
1 aggc tgtc aatg
13 ctag gcat agaa
25 gtcg tgct gtag
37 agat agtc tgat
49 agtc gc
However, I always get the following output:
1 aggc tgtc aatg13 ctag gcat agaa25 gtcg tgct gtag37 agat agtc tgat49 agtc gc
I'm not sure how to get a new line where it is supposed to be. Can someone help me with this? Thanks a lot!
Here is my code so far that created this output (it is part of a certain function):
to_return += f'{str(index_row): >} {block_row}'
return to_return
EDIT: I came across another problem: Does anyone know how I can align the 1 in the first row to the right? I thought that the ">" sign in my code would do the trick, but my 1 stays aligned to the left side.
Just add the newline character (\n
) to the end of your string:
to_return += f'{str(index_row): >} {block_row}\n'
return to_return