Identify the error in following code:
(i) List1 = [10,20,30,40]
List1[4]=100
(ii) Name=”Michael Jackson”
Name[2]=”k”
Answers
Answered by
1
Answer:
i) Out of index error
ii) Assignment error
Explanation:
i) When you mention List[4]=100, you're asking the program for the element on 4th index of list, which is not present.
The list you mentioned goes till index 3 as indexing begins with 0.
ii) You cannot assigns a defined value an identifier instead you do the reverse.
k=Name[2] is valid.
Similar questions