Improve your Python skills with Exercise 9: Strings | HolyPython.com
Python String Exercises
Let’s check out some exercises that will help you understand Python strings better.
Exercise 9-a
Assign the string below to the variable in the exercise.
"It's always darkest before dawn."
All you need to do is make sure your string is inside quotation marks.
str = "It's always darkest before dawn."
Exercise 9-b
By using first, second and last characters of the string, create a new string.
You can add strings by using (+) character.
ans_1 = str[0]+str[1]+str[-1]
Exercise 9-c
You can’t directly change a string, because they’re immutable. But you can use .replace() method and assign a new string to the same variable.
.replace() will take two arguments, first: value to replace, second: new value.
str = str.replace(".", "!")Need More Exercises?
Check out Holy Python AI+ for amazing Python learning tools.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.

Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython