Percent with two decimals in a fixed-width column

FreyaLOP

99.80% — how do I keep the trailing zero?

1

Comments 4

Join the discussion

Already have an account? Log in

  1. EmmaCodesreplies: 2

    Use a format spec with two decimals and a width, e.g. right-aligned .2f followed by "%". Rounding with round() would drop the trailing zero; formatting keeps it.

    1
    1. OllieGrant

      "text".center(WIDTH) for the title is neat. Didn't know strings had center().

      1