Y
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
thaumasiotes
1960 days ago
That is the opposite of the problem being posed. The question is how you define `greet` using f-strings.
link
sumzup
1960 days ago
greet = lambda x: f"hello {x}"
link