Question Detail
Question
Given the Python code snippet:
word = "Python"What will be the output?
print(word[0:2])
Correct Answer
Option B is the correct answer.
Detailed Explanation
String slicing
word[start:stop] includes the character at the start index but excludes the character at the stop index. So, word[0:2] includes index 0 ('P') and index 1 ('y'), but excludes index 2 ('t').
Hint
Remember the 'Off-By-One Reminder' for slicing: the stop index is excluded.