0
How can be answer Line 4? There is just 3 output...
How can cause a error line 4? there is just 3 lines with print request. Which line of code will cause an error? num = [5, 4, 3, [2], 1] print(num[0]) print(num[3][0]) print(num[5])
2 Answers
+ 5
Please use appropriate tags for your question.
So, your list contains only 5 elements but lists indexing starts from 0 which means
5 is at index 0
4 is at index 1
3 is at index 2
2 is at index 3
1 is at index 4
So, in order to print the last item of the list, you have to use:
print(nums[4]).
Running your code gives an index error which means that the item of that index doesn't exists
+ 3
the last print request is the 4th line.
#it starts with
1. num =...
...
#And ends with
4. print(num[5])
Read the error type, it tends to tell you the problem. You went out of range with the index of 5. max of that list is 4