Italic String in Python

  • Post category:String

In this article, you will see how to italic string in Python. In Python, you can use the string format() method to italicize a string. In the below code, 3m{} is used to italic a string.

Step 1: Create a string

str = "CodeAllow"
print("str = ", str)
print("str type = ", type(str))

Step 2: Italic string

print("str = ", "\033[3m{}\033[0m".format(str))

Output:

str =  CodeAllow
str type =  <class 'str'>
str =  CodeAllow

Free resources to learn advanced skills: AiHints and CodeAllow