STRINGS in python are arrays of bytes representing Unicode characters, in python syntax string is represented by enclosing characters in single or double quotes for one liner statement. And Multiline strings are represented by enclosing it in three double or three single quotes.
Example Code |
a=’Hello World’ print(a) b=”Hello World” print(b) c=”””This is multiline string statement!””” print(c) d=”’This is multiline string statement!”’ print(d) print(a[0],a[1]) |
- ‘Hello World’ is the same as “Hello World”.
- Three single quotes or three double quotes are used for multiline string statements.
- Square brackets can be used to access elements of the string, the index of the first character starts from 0.
Output |
Hello World Hello World This is multiline string statement! This is multiline string statement! H e |