I am attempting to handle errors within an f-string, but my attempts don't seem to work. Is there a way to accomplish this?
string = f"For example I thought this syntax would work but it doesn't {try: 5/0 except Exception: str(infinity)}"
You can't. Move the exception handling out of the f-string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With