CBSE Class 12 Computer Science Question 34 of 105

Python Revision Tour — Question 18

Back to all questions
18
Question

Question 18

For a given declaration in Python as s = "WELCOME", which of the following will be the correct output of print(s[1::2])?

  1. WEL
  2. COME
  3. WLOE
  4. ECM
Answer

ECM

Reason — The slicing will start from index 1 and return at every alternative step.

s[1] = E
s[3] = C
s[5] = M
output = ECM