[Tutor] What is this code doing? What is it?

Matthew Polack matthew.polack at htlc.vic.edu.au
Sun May 12 07:31:45 EDT 2019


We're beginners  trying to learn Python and have this sample code:

https://github.com/PySimpleGUI/PySimpleGUI/blob/master/ProgrammingClassExamples/Win10%20versions/2a.%20PSG%20(checkbox%20and%20radiobuttons)%20-%20Copy.py


There is a section of code that has this line::

result = str(' Cost: ' + '${:.2f}'.format(cost))

But I don't understamd what the curly brace part is actually doing:
{:}

'${:.2f}'

I think the 2f means to use 2 decimal places...but what does the rest of
this do?

..curly braces apparenly are for dictionaries...but I don't get how this is
a dictionary..or what this {:} command is actually doing?

Thanks for any clues or links to an easy to understand tutorial or
something on this feature.

- Matt

-- 
**Disclaimer: *Whilst every attempt has been made to ensure that material 
contained in this email is free from computer viruses or other defects, the 
attached files are provided, and may only be used, on the basis that the 
user assumes all responsibility for use of the material transmitted. This 
email is intended only for the use of the individual or entity named above 
and may contain information that is confidential and privileged. If you are 
not the intended recipient, please note that any dissemination, 
distribution or copying of this email is strictly prohibited. If you have 
received this email in error, please notify us immediately by return email 
or telephone +61 3 5382 2529** and destroy the original message.*


More information about the Tutor mailing list