Indexing and Slicing Strings
Escape sequences:
\n # Prints on new lineIndexing:
sentence = 'this is a sentence'
# to print t
print(sentence[0])
# to print last
print(sentence[-1])String slicing:
# to get the first word
print(sentence[0:4]) # prints 0 to 3
# prints thisSlinging the data in increment of 2 (every other char)
sentence = 'abcdefg'
print(sentence[0:7:2]) # Last colon prints increment
# prints acegGetting strings only from a certain point forward
# don't need abc
print(sentence[3:])
#prints defgLast updated