adplus-dvertising
frame-decoration

Question

What is the output of the following code?
a=["Apple","Ball","Cobra"]
<br class="blank" />a.sort(key=len)
print(a)

a.

[‘Apple’, ‘Ball’, ‘Cobra’].

b.

[‘Ball’, ‘Apple’, ‘Cobra’].

c.

[‘Cobra’, ‘Apple’, ‘Ball’].

d.

Invalid syntax for sort().

Posted under Python

Answer: (b).[‘Ball’, ‘Apple’, ‘Cobra’].

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the following code?