Lists | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson


Which line of code will cause an error? num = [5, 4, 3, [2], 1] print(num[0]) print(num[3][0]) print(num[5]) Tell the answer.

16th Aug 2020, 1:11 PM
Jash Sampat
3 Answers
Indexerror in last line
16th Aug 2020, 1:47 PM
Allamprabhu Hiremath
+ 5
The last line i.e print(num[5]) will cause an error because that item doesn't exists in the list. So, I think it will cause an index error. But, you should Check it yourself. Why we will give you the error line or output. We're not interpreter or complier or IDE. These things you can check it yourself. A meaningful question you would have asked should look something like this: Why this is causing an error??? ............. Or Why the output is .....?? ..... So, try to ask meaningful and relevant questions.
16th Aug 2020, 1:41 PM
Arctic Fox
Arctic Fox - avatar
Run and see simple 😁
16th Aug 2020, 1:34 PM
Prasad Bankar
Prasad Bankar - avatar