how to print bold font when using f-string?

Viewed 5485
2 Answers

It is the same as the regular string Try this:

name = 'Yacoub'
age = 23
print(f"This is \033[1mbold\033[0m and my name is \033[1m{name}\033[0m\nI am \033[1m{age}\033[0m years old")

Output:

This is bold and my name is Yacoub

I am 23 years old

did you try doing? :

a_string = "abc"
bolded_string = f"\033[1m{a_string}\033[0m"
print (bolder_string)

enter image description here

Related