A. ✅ Valid – "python".index("th")
This returns the starting index of substring "th" in "python" → 2.
→ Correct
B. ❌ Invalid – rfind("python","r")
rfind is a string method, not a standalone function.
Also, "r" isn't a valid parameter for rfind() in this context.
→ Error: NameError or TypeError
C. ❌ Invalid – "python".sort()
Strings do not have a .sort() method (only lists do).
→ AttributeError
D. ✅ Valid – sorted("python")
This returns a sorted list of the characters: ['h', 'n', 'o', 'p', 't', 'y'].
→ Correct
Explanation:
The correct answers are:
A. "python".index("th")
The index() method is used to find the starting index of a substring within a string.
"python".index("th") returns 2, as the substring "th" starts at index 2 in the string “python".
Example:

result = “python".index("th")
print(result) # Outputs: 2
D. sorted("python")
The sorted() function returns a new sorted list containing the characters of the string "python" in alphabetical order.
Example:

result = sorted("python")
print(result) # Outputs: ['h', 'n', 'o', 'p', 't', 'y']
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Abbribas
1Â week, 1Â day agoflthymcnsty
7Â months, 2Â weeks ago