0

So I just learned about f-strings, and I like how efficient they can be, but I was wondering if there's a way I can use them to replicate something I do for some extremely simple code (mostly just math calculations for myself):

Say I have a function that returns a tuple:

def add(a, b):
   return a, b, a+b

I can then use that in a print statement with .format and * to distribute the contents of the tuple:

print("The sum of {} and {} is: {}".format(*add(1,2)))

Is there a way I can replicate this with an f-string?

sj95126
  • 6,520
  • 2
  • 15
  • 34
Netforce23
  • 15
  • 4
  • ah, yeah I just meant that as a simple example; an actual use case would be to have the function return a few different calculations on the arguments – Netforce23 Sep 19 '22 at 00:38

0 Answers0