✍️Introduction
In Python, a string is used to store text data.
Strings are one of the most important data types and are used in almost every Python program.
In this article, you will learn:
-
What strings are
-
How to create strings
-
String operations
-
Common string methods with examples
What is a String in Python?
A string is a sequence of characters enclosed inside:
-
Single quotes
' ' -
Double quotes
" "
Example:
name = "Python"
Creating Strings in Python
Both are valid in Python.
Accessing Characters in a String
Each character has an index number, starting from 0.
4️⃣ find()
5️⃣ split()
❌ Strings are Immutable
Strings cannot be changed after creation.
Wrong:
Correct:
Comments
Post a Comment