CBSE Class 11 Computer Science
Question 66 of 104
List Manipulation — Question 2
Back to all questions 2
Question Question 2
Given two lists:
L1 = ["this", 'is', 'a', 'List'], L2 = ["this", ["is", "another"], "List"]
Which of the following expressions will cause an error and why?
- L1 == L2
- L1.upper( )
- L1[3].upper( )
- L2.upper( )
- L2[1].upper( )
- L2[1][1].upper( )
Answer
- L1.upper( ) will cause an error as upper() method can be called with Strings not Lists.
- L2.upper( ) will cause an error as upper() method can be called with Strings not Lists.
- L2[1].upper( ) will cause an error as L2[1] is a list — [ "is", "another"] and upper() method cannot be called on Lists.