KnowledgeBoat Logo

Computer Science

Given two lists:

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

Which of the following expressions will not result in error? Give output of expressions that do not result in error.

  1. L1 == L2
  2. L1.upper( )
  3. L1[3].upper( )
  4. L2.upper( )
  5. L2[1].upper( )
  6. L2[1][1].upper( )

Python List Manipulation

20 Likes

Answer

  • L1 == L2 gives output as false because L1 is not equal to L2.
  • L1[3].upper( ) gives output as 'LIST' because L1[3] is 'List' and upper() function converts it to uppercase.
  • L2[1][1].upper( ) gives output as 'ANOTHER' because L2[1] ["is", "another"] and L2[1][1] is "another". upper() function converts it to uppercase.

Answered By

12 Likes


Related Questions