Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print repeating string with f-string

I can print(‘#’*5) to >>> #####.

But if I try to do this with f-string like

a=5
print(f” ‘#’*{a}”) 

I get >>> ‘#’*5. Is this not possible, or what is my failure?

like image 899
Paul-ET Avatar asked Jun 10 '26 16:06

Paul-ET


1 Answers

You can do:

a=5
print(f"{'#'*a}")

To get

#####
like image 175
Aziz Avatar answered Jun 20 '26 22:06

Aziz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!