Strings and String Operations in Python
Python Made Easy - (Article 10) Telugu Explanation
1. What is a String?
String ante - text ni represent cheyyadaniki use chese data type.
Words, sentences, letters - anni string lo store cheyyachu.
Get D Naresh’s stories in your inbox
Join Medium for free to get updates from this writer.
Example:
name = "Naresh"
message = 'Python is easy'Output:
Naresh
Python is easyImportant:
- Strings are written inside quotes —
" "or' '. - String means a sequence of characters.
- Example:
"Naresh"→ N, a, r, e, s, h (6 characters)
2. Accessing Characters (Indexing)
Python lo string ni character by character access cheyyachu using index number.
Index always starts from 0.
name = "Naresh"
print(name[0]) # N
print(name[1]) # a
print(name[-1]) # h (last character)3. Slicing Strings (Part of String)
String lo portion (part) tiskovali ante slicing use chestam.
word = "Python"
print(word[0:3]) # Pyt
print(word[2:]) # thon
print(word[:4]) # PythSyntax:
string[start:end]
- start → include
- end → exclude
4. String Length
len() function use chesi string lo letters count cheyyachu.
text = "Hello"
print(len(text))Output:
55. Strings are Immutable
Means → you can’t change characters directly.
name = "Naresh"
name[0] = "K" # ❌ ErrorOutput:
TypeError: 'str' object does not support item assignmentSo, strings are immutable (unchangeable).
Kaani, new string create cheyyachu.
name = "Naresh"
new_name = "K" + name[1:]
print(new_name)Output:
Karesh6. Common String Operations
Concatenation (Joining)
a = "Python"
b = "Rocks"
print(a + " " + b)Output:
Python RocksRepetition
word = "Hi! "
print(word * 3)Output:
Hi! Hi! Hi!Membership
text = "I love Python"
print("love" in text) # True
print("Java" not in text) # True7. String Methods (Built-in Functions)
8. Loop Through a String
name = "Naresh"
for ch in name:
print(ch)Output:
N
a
r
e
s
h9. Example Programs
Example 1: Count Vowels in a String
text = "python programming"
vowels = "aeiou"
count = 0
for ch in text:
if ch in vowels:
count += 1
print("Vowel count:", count)Output:
Vowel count: 4Example 2: Palindrome Check
(Palindrome ante word lo letters ni reverse chesina same word vastundhi)
word = "madam"
if word == word[::-1]:
print("Palindrome!")
else:
print("Not a palindrome.")Output:
Palindrome!Example 3: Reverse String
text = "Python"
print(text[::-1])Output:
nohtyP10. Summary / Key Takeaways
- String = Text data stored inside quotes.
- Indexing → access letters.
- Slicing → cut portions of string.
- Strings are immutable.
- Useful methods →
upper(),lower(),replace(),split(),join(). - Loops → used to check or count characters.
Practice Questions
1️.Create a string "Hello Python" and print only "Python".
2️.Write a program to count vowels and consonants.
3️.Reverse a given string using slicing.
4️.Replace "Python" with "AI" in a sentence.
5️.Split a sentence into words and join them back with -.
Previous & Next
Next Article : 👉11.Object Oriented Programming (OOP’s)
Previous Article: 👉9.Data Structures in Python









