How can I set a python f-string format programmatically?
I would like to set the formatting of a number in an fstring programmatically. Specifically, I have an integer that can span several orders of magnitude and I’d like to print it using the underscore “_” delimiter, e.g.
Why would I need to format an integer in a formatted string in Python?
print(f”Add {200} grams of flour.”)
Star is causing an unterminated f-string literal
The following code
What does ‘!a’ do in python f-strings?
When messing around in python with the exclamation mark, it said that it has to be followed by either !a
, !s
, or !r
.
What does !a
do?
Return Output from Function on Multiple Lines
I’ve tried to figure this out on my own, but I’m coming to a dead end. I’m trying to return a string from a function that I created that references amounts derived from a pandas dataframe that was created earlier in the function, and I want each variable reference to be shown as it’s own line as the output: