Strings are immutable: you cannot change a character in place.
💡 Key Takeaways: Python Strings
Mastering Python Strings helps you write clean and reliable Python code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
Python Strings Code Example
Python
s = "CodesInTech"
print(s[0], s[-1])
print(s[0:5])
print(s[5:])
print(s[::-1])
print(len(s))
print("Tech" in s)
for ch in "abc":
print(ch)
Free sign-in required · Google login available
Python Strings Practice Exercises
Check what you learned in “Python Strings”.
/ 3 solved
Fill in the blank
Get the last character of the string.
last = word[ ]
✓ Correct!Not quite. Try again.
Multiple choice
What does "Python"[0:2] return?
✓ Correct!Not quite. Try again.
Code challenge
Print the word reversed using slicing.
Write the code in the live editor. Your answer is checked automatically.