Q. Given two lists


L1 = ["this", "is", 'a', "List"]

L2 = ["this", ["is", "another"], "List"]


Which of the following expressions will cause an error and why?


(a)

L1 == L2


(b)

L1.upper ( )


(c)

L1[3].upper()


(d)

L2.upper ()


(e)

L2[1].upper()


(f)

L2[1][1].upper()



Answer =

Expressions that will cause an error:-

(b) (d) & (e) Because upper() function convert only alphabets from smaller alphabets to upper alphabets. But in a given expression L1, L2, L2[1] respectively are list.

Note: - Here L2[1] is nested list.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post