QuestionQ107

VerifiedStrings

Assuming the following snippet has executed successfully, which of these expressions evaluates to True?

string = 'python'[::2]  
string = string[-1] + string[-2]  
Explanation

The slice 'python'[::2] produces 'pto'. Reversing its final two characters with string[-1] + string[-2] produces 'ot', whose first character is 'o'. No other listed expression evaluates to True.

Community Discussion

No comments yet. Be the first to start the discussion!