Python Strings
Python Strings
STRINGS
R.K.SUSHMITA LAKSHME
WHAT IS STRING
A String is a data structure in Python that represents a
sequence of characters.
It is an immutable data type
Strings are used widely in many different applications,
such as storing and manipulating text data,
representing names, addresses, and other types of
data that can be represented as text.
CREATING A STRING IN PYTHON
Strings in Python can be created using single quotes or double quotes or even triple quotes.
Let us see how we can define a string in Python.
ACCESSING CHARACTERS IN
PYTHON STRING
STRING SLICING
In Python, the String Slicing method is used to access a range of characters in the
String. Slicing in a String is done by using a Slicing operator, i.e., a colon (:).
REVERSING A PYTHON
STRING
By accessing characters from a string, we can also reverse strings in Python. We can Reverse a
string by using String slicing method.
Example:
In this example, we will reverse a string by accessing the index. We did not specify the first
two parts of the slice indicating that we are considering the whole string, from the start index
to the last index.
Initial String:
NameError: name 'String1' is not defined
Hello, I'm a Geek
Updating character at 2nd Index:
Heplo, I'm a Geek
02 - WEBSITE
THANK YOU