Hacker News new | ask | show | jobs
by eljost 1960 days ago
You can use variables in the formats.

  >>> flt = 1.2345
  >>> two = 2
  >>> f"{flt:.{two}f}"
  '1.23'
1 comments

That is the opposite of the problem being posed. The question is how you define `greet` using f-strings.

  greet = lambda x: f"hello {x}"