Python Advanced #11 - Reading Two Columns from a Non-Justified Text File and Saving to a Justified Text File

In Python Advanced #10, we read two columns from a non-justified text file and saved those values into lists.  Recall that the non-justified text file was as follows:



Using the code developed in Python Advanced #10 and adding code to write the results of the lists named vals1 and vals2 to a text file, the code is as follows:



However, when we look at the resulting text file, we can see that the values are not justified.



To solve this issue, I use rjust in the write statement to right justify the values.  Note that the number in the parentheses specifies the desired width of the column.  The new write statement now looks like this:



The output from changing this write statement is shown below:




Comments