Q:

How do I right align monetary values with the "$" next to each number, not just at the margin?

I am trying to right align some monetary values to look like this:
John Smith         $3,500
Jane Doe             $200
Jack Johnson         $700

But I am getting this:
John Smith         $3500
Jane Doe           $ 200
Jack Johnson       $ 700.

My code for the output looks like this:
for (name, amount) in cursor:
    print("{}".format(name)+ "\t\t\t" + "${:>5,.0f}".format( amount))

I would also like to put a comma separator for numbers in the thousands. I know I've seen the formatting for this before, but I am having trouble finding it again.

A:

Try this, remove the spaces at both sides of the number string.
for (name, amount) in cursor: 
    print("{}".format(name)+ "\t\t\t" + "{:>5}".format("$"+ "{:.0f}".format(amount).strip()))

