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 |
Leave a Reply