What is the value of 'python'[1:4]?
-
A
'ytho'
-
B
'yth'
Correct answer
-
C
'pyt'
-
D
'pyth'
20 views
Explanation
Slicing includes the start index and excludes the stop: indexes 1, 2 and 3 are 'y', 't' and 'h'.
Reference
Asked in: NTS, PPSC, Python Developer Interviews
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ