git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Print formatting


I seem to have found a way to do this with the following:

 print('{:<12s}{:>12s}'.format((temp_list[0]),(temp_list[3])))

Still let me know if there is a better way to format this output :)

Thanks,
-J

On Fri, Oct 18, 2019 at 10:03 AM Jagga Soorma <jagga13 at gmail.com> wrote:
>
> Hello,
>
> I am new to python and trying to write a script that outputs some data
> about users.  I was able to write it and dump the data but can't seem
> to align the output in column 2 correctly.  Here is what I am trying
> to do:
>
> --
> output:
> user1     data1
> username2             data2
> user3     data3
>
> snip from script:
> print(str(temp_list[0]) + "\t\t" + str(temp_list[1]))
> --
>
> Adding the tabs does not seem to work and I am sure there is a better
> way to do this.  Any help would be appreciated.
>
> Thanks,
> -J