Question:

Consider the statements given below and then choose the correct output from the given options:
L = ['TIC', 'TAC']
print(L[::-1])

Show Hint

In Python, [::-1] reverses the list or string completely.
It does not reverse the individual elements unless specified.
  • ['CIT', 'CAT']
  • ['TIC', 'TAC']
  • ['CAT', 'CIT']
  • ['TAC', 'TIC']
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

The list L is defined as ['TIC', 'TAC'].
The slicing notation [::-1] is used to reverse the entire list.
So, L[::-1] will reverse the order of the elements in the list.
The first element 'TIC' will move to the last position,
and the second element 'TAC' will move to the first position.
Therefore, the output will be ['TAC', 'TIC'].
Options (A) and (C) show the reversed strings, but the strings themselves are not reversed — only the list is reversed.
So, option (D) is the correct answer.
Was this answer helpful?
0
0

Top Questions on Programming in Python

View More Questions

Questions Asked in CBSE CLASS XII exam

View More Questions