chai = "Masala Chai"
print(chai[0:6]) # Masala → gets characters from index 0 to 5
print(chai.lower()) # masala chai → converts all to small letters
print(chai.upper()) # MASALA CHAI → converts all to capital letters
print(chai.strip()) # Masala Chai → removes space from start and end only
print(chai.replace("Masala", "Lemon")) # Lemon Chai → replaces word
print(chai.find("Chai")) # 7 → shows starting index of word
print(chai.count("Chai")) # 1 → counts how many times word appears
✅ split() – splits string into list#
chai_list = "Lemon, Ginger, Masala, Mint"
print(chai_list.split()) # ['Lemon,', 'Ginger,', 'Masala,', 'Mint'] → split by space (default)
print(chai_list.split(", ")) # ['Lemon', 'Ginger', 'Masala', 'Mint'] → split by comma + space
✅ String Slicing#
num = "0123456789"
num[:] # '0123456789' → full string
num[3:] # '3456789' → from index 3 to end
num[:7] # '0123456' → from start to index 6
num[0:7:2] # '0246' → step 2 from index 0 to 6
num[0:7:3] # '036' → step 3 from index 0 to 6
chai_type = "Masala"
quantity = 2
statement = "I ordered {} cups of {} chai"
print(statement.format(quantity, chai_type))
# Output: I ordered 2 cups of Masala chai