Class 11:Python String Literals

Python Strings/String Literals

String literals in python are surrounded by either single quotation marks or double quotation marks.
‘hello’ is the same as “hello”.

Strings can be output to the screen using the print function. For example print(“hello”).

 

Like many other popular programming languages, strings in Python are arrays of bytes representing Unicode characters. However, Python does not have a character data type, a single character is simply a string with a length of 1. Square brackets can be used to access elements of the string.

Examples
>>> a=”hello”
>>> print(type(a))
<class ‘str’>

>>> a="hello"
>>> print(type(a))
<class 'str'>