String notations and concepts
Strings are sequences of characters. Python provides a rich set of operations and functions that can be applied to the string data type. Strings are textual data and are handled very efficiently in Python. The following is an example of a string (s)
—"packt publishing"
.
A substring is a sequence of characters that’s part of the given string, i.e., specified indices in the string in a continuous order. For example, “packt
" is a substring of the string “packt publishing
". On the other hand, a subsequence is also a sequence of characters that can be obtained from the given string by removing some of the characters from the string by keeping the order of occurrence of the characters. For example, “pct pblishing
" is a valid subsequence for the string “packt publishing
" that is obtained by removing the characters a
, k
, and u
. However, this is not a substring since “pct pblishing...