I have a couple of lists with progressively decreasing number of items like below:
list1 = [10 20 30]
list2 = [50 60]
list3 = [80]
I want to print the lists such that the last item of the succeeding lists after the 1st list is flushed-right, i.e, the last items of the lists, e.g. 30 60 80 are aligned under the last column of list1.
Here's a snippet of my list and the codes that I used to display the list as I wanted:
s1 = [4.98, 14.41, -3.16, 2.74. -12.32]
s2 = [-6.59, 14.14, 8.84, 5.68]
s3 = [-29.95, 18.95, 15.75]
s4 = [11.44, -8.22]
s5 = [30.96]
The lists show flushed-left when printed, all first items aligned in col 1. As I mentioned, I want to print it fushed-right, all last items aligned together in the last column of list s1.
I padded the "blanks" of lists whose lengths are less than list s1 with a dummy item ('zzzz') to see if I could print flushed-right.
Pad1 = ['zzzz']
Pad2 = ['zzzz', 'zzzz']
Pad3 = ['zzzz', 'zzzz', 'zzzz']
Pad4 = ['zzzz', 'zzzz', 'zzzz', 'zzzz']
df_join1 = Pad1 + s2
df_join2 = Pad2 + s3
df_join3 = Pad3 + s4
df_join4 = Pad4 + s5
Padding works, got the last item of each list to print flushed right but the outlook is ugly as the numbers in columns are not properly aligned.
There must be a better way to do it. Would greatly appreciate a useful lead. I must admit, my script codes aren't the most efficient. I can clean them up later. For now, I just want to see if there's a better way.
Much thanks.