WHAT IS THE STRING TYPE IN PYTHON?

615 viewsPYTHONPython
0

WHAT IS THE STRING TYPE IN PYTHON?

Saraswat World Changed status to publish June 14, 2023
0
Strings in Python
Strings in Python

 

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
Saraswat World Changed status to publish June 14, 2023
Write your answer.

Posted

in

Tags:

Comments

Leave a Reply

Ganesh Ji Arti A Tribute to Dilip Kumar