Question:medium

Assertion (A): The expression "HELLO".sort() in Python will give an error. 
Reason (R): sort() does not exist as a method/function for strings in Python. 
Mark the correct choice: 
 

Show Hint

Use sorted()} to sort characters in a string after converting it to a list using list()}.
Updated On: Jan 13, 2026
  • Both (A) and (R) are true and (R) is the correct explanation for (A).
  • Both (A) and (R) are true and (R) is not the correct explanation for (A).
  • (A) is true but (R) is false.
  • (A) is false but (R) is true.
Show Solution

The Correct Option is A

Solution and Explanation

Python strings lack a defined sort() method; this method is exclusive to lists. Consequently, attempting to sort a string, such as "HELLO", by calling sort() will trigger an AttributeError. Both the assertion (A) and the reasoning (R) are accurate, and (R) provides a correct explanation for (A).

Was this answer helpful?
0

Top Questions on Miscellaneous