KnowledgeBoat Logo
|

Computer Science

Find the errors:

  1. L1 = [1, 11, 21, 31]
  2. L2 = L1 + 2
  3. L3 = L1 * 2
  4. Idx = L1.index(45)

Python List Manipulation

26 Likes

Answer

  • Line 2 — L2 = L1 + 2 will result in error as one element of + is a list and other is an integer. In Python, operands of + operator should be of same type.
  • Line 4 — Idx = L1.index(45) will cause an error as 45 is not present in the list L1.

Answered By

10 Likes


Related Questions