What is String in Python?
What is slicing?
We can use a [:]
to perform slicing which grabs everything up to a designated point.
for [2:] Grab everything past the first term all the way to the length of string
for [:4] Grab everything up to the 4th index
for [ : ] Grab everything
for [:: 2] Grab everything but go in step sizes
of 2 ( that means jump 2 in forwarding)
for [:: -1 ] We can use this to print a string backward let's understand with examples on Jupiter notebook
String Properties :
It's important to note that
strings have an important property known as immutability. This means that once
a string is created, the elements within it can not be changed or replaced.
Objects in Python usually
have built-in methods. These methods are functions inside the object (we will
learn about these in much more depth later) that can perform actions or
commands on the object itself.
We call methods with a period and then the method name. Methods are in the form:>>> object.method(parameters)
Where parameters are extra arguments we can pass into the method are given below let's have example one by one
string.upper() to convert string in upper case
string.lower() to convert string in lower case
string.split() split a string by blank space
for more details, you simply check out the documentation https://www.python.org/doc/ and for any query just comment in the box so that I solve your queries as soon as possible.

Comments
Post a Comment