Goseeko blog

What is a Python String?

by Bhumika

In Python, strings are byte arrays that represent Unicode characters. Due to the lack of a character data type in Python, a single character is simply a one-length string. The elements of the string can be accessed using square brackets.

The term “string” refers to a series of characters. A symbol is all that a character is. For example, the English language includes 26 characters. Computers function with numbers rather than text (binary). Although you may see characters on your screen, they are actually a series of 0s and 1s that are saved and updated internally.

Moreover, The process of turning a character to a number is known as encoding, and the process of decoding is known as decoding. Moreover, ASCII and Unicode are two of the most commonly utilized encodings.

How to access characters in a string?

Individual characters can be accessed using indexing, whereas a set of characters can be accessed using slicing. Furthermore, The index starts at zero and goes up from there. Furthermore, You’ll get an IndexError if you try to access a character outside of the index range. As the index, an integer must be used. We can’t use floating or other types because we’ll get a TypeError.

Negative indexing is possible in Python sequences.

The index -1 represents the last item, the index -2 represents the second last item, and so on. We can retrieve a list of objects in a string by using the slicing operator: (colon).

How to create a string in Python?

Characters are encased within single or double quotation marks to make strings.Triple quotes can be used to represent multi line texts and docstrings in Python, but they are most usually employed to do so.

#Using single quotes  

str1 = ‘Hii Python’  


#Using double quotes  

str2 = “Hii Python”  


#Using triple quotes  

str3 = ””’Triple quotes are generally used for  

    represent the multiline or 



Interested in learning about similar topics? Here are a few hand-picked blogs for you!

  1. What is JDBC connectivity?
  2. Describe programming?
  3. What is object oriented programming?
  4. Explain Recursion?

You may also like