English

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

Advertisements
Advertisements

Question

Consider the statements given below and then choose the correct output from the given options:

L=[‘TIC’, ‘TAC’]
print(L[::-1])

Options

  • [‘CIT’, ‘CAT’]

  • [‘TIC’, ‘TAC’]

  • [‘CAT’, ‘CIT’]

  • [‘TAC’, ‘TIC’]

MCQ
Advertisements

Solution

[‘TAC’, ‘TIC’]

Explanation:

The slice L[::-1] reverses the order of elements in the list, so the list is printed in reverse.

shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×