![]() |
how to use .format? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: how to use .format? (/thread-37721.html) |
how to use .format? - Frankduc - Jul-13-2022 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? RE: how to use .format? - Gribouillis - Jul-13-2022 Try "Il fait: {} degrés.".format(str(w.temperature('celsius')['temp'])) RE: how to use .format? - Frankduc - Jul-13-2022 I should of tried that before. Thank you Gribouillis RE: how to use .format? - snippsat - Jul-13-2022 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.") |