Python Character literal
It is also a type of Python string literal where a single character is surrounded by single or double quotes.
Python3
# character literal in single quote v = 'n' # character literal in double quotes w = "a" print (v) print (w) |
Output
n
a
Literals in Python
A literal in Python is a syntax that is used to completely express a fixed value of a specific data type. Literals are constants that are self-explanatory and don’t need to be computed or evaluated. They are used to provide variable values or to directly utilize them in expressions. Generally, literals are a notation for representing a fixed value in source code. They can also be defined as raw values or data given in variables or constants. In this article, we will explore the different types of literals in Python, along with examples to demonstrate their usage.