Strings in Python

In Python, String are declared either by using single or double quotes.
print("Welcome to Neoogy")
print('Welcome to Neoogy')

Output will be
Welcome to Neoogy
Welcome to Neoogy


Assign String to a Variable:
mystr="Welcome to Neoogy"
print(mystr)

Output will be
Welcome to Neoogy


Strings Indexing:
Like many other popular programming languages, the indexing of strings in Python starts from 0. Square brackets can be used with index value to access elements of the string.
mystr="Neoogy" #Index: N=0, e=1, o=2, o=3, g=4, y=5
print(mystr[1])

Output will be
e


0 Comments