Skip to content

Commit

Permalink
Add explanation to formats in 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
uatach committed May 12, 2024
1 parent 5b941e5 commit eb04e27
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Doc/tutorial/inputoutput.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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%'

Expand Down

0 comments on commit eb04e27

Please sign in to comment.