Question:medium

Question: Select the correct output of the following code:

event = "G20 Presidency@2023"
L = event.split(' ')
print(L[::-2])
    

Show Hint

Use list[::-step]} to reverse or skip elements in a list. The step size determines how elements are selected.
Updated On: Jan 13, 2026
  • 'G20'
     

  • 'Presidency@2023' 
     

  • 'G20'
     

  • 'Presidency@2023'
     

Show Solution

The Correct Option is C

Solution and Explanation

Question: The split() method, when applied to the string "G20 Presidency@2023" with spaces as delimiters, produces the following list:


L = ["G20", "Presidency@2023"]

The slicing operation L[::-2] works as follows:

  • The slice [::-2] reverses the list and selects elements with a step of −2.
  • From the reversed list, the element "G20" is selected.

Therefore, the result of L[::-2] is:


['G20']
Was this answer helpful?
0

Top Questions on Commands and Requests