What will be the output for the below code?
list1 = ["abc", "bcd", "def"]
print(list 1(-1)(-11)
Answers
Answered by
1
Answer:
Its a straight Syntax error.
The Line 2 is supposed to be this --> list1[-1][-11]
Explanation:
It is a list slicing operation. The first -1 points to the last position of the list which is "def"
The second position points to the Letters of the string. But considering that the string is only of length 3 , the -11 will return a error "string index out of range"
But if you meant -1 it is the last letter ofthe word "def" which is 'f'
O/p:
"f"
Similar questions