Python Forum

Full Version: how to use .format?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I would like to add degree at the end of the phrase.
"Il fait: {}".format(str(w.temperature('celsius')['temp']))
Like:

"Il fait: {}".format(str(w.temperature('celsius')['temp'], "degree"))

but its not how to do it. anyone know how?
Try
"Il fait: {} degrés.".format(str(w.temperature('celsius')['temp']))
I should of tried that before.
Thank you Gribouillis
Should not use str as gone be inside a string(that is of type str)
Also make more sense now to use f-string as it has been in Python now for 6-years.
print(f"Il fait: {w.temperature('celsius')['temp']} degrés.")