21. Which method is used to split a string into a list of substrings based on a specified separator?
22. What is the purpose of the find() method for strings?
23. What is the output of the following code:
string = "Python is fun"
print(string.split())
string = "Python is fun"
print(string.split())
24. In Python, how can you check if a string ends with a specific substring?
25. What is the purpose of the join() method for strings?
26. What is the output of the following code:
string = "Python"
print(string.find("th"))
string = "Python"
print(string.find("th"))
27. Which method is used to remove leading and trailing whitespace from a string?
28. What will be the output of the following code:
string = "Hello, world!"
print(string.replace("o", "i"))
string = "Hello, world!"
print(string.replace("o", "i"))
29. What is the purpose of the title() method for strings?
30. In Python, how can you check if a string contains only numeric characters?
Read More Section(Strings in Python)
Each Section contains maximum 100 MCQs question on Strings in Python. To get more questions visit other sections.