From eb04e279fcbf856d5f4c907fbd57e575d954175f Mon Sep 17 00:00:00 2001 From: edson duarte Date: Sun, 12 May 2024 11:24:29 -0300 Subject: [PATCH] Add explanation to formats in 7.1 --- Doc/tutorial/inputoutput.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index fe9ca9ccb9c7e0..ab11b90d251eae 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -44,6 +44,8 @@ printing space-separated values. There are several ways to format output. >>> yes_votes = 42_572_654 >>> no_votes = 43_132_495 >>> percentage = yes_votes / (yes_votes + no_votes) + >>> # Print yes_votes padded with spaces and a negative sign only for negative numbers + >>> # Also print percentage multiplied by 100, with 2 decimal places and followed by a percent sign: >>> '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage) ' 42572654 YES votes 49.67%'