QuestionQ97

VerifiedStrings

Assuming the following snippet has executed successfully, which expressions evaluate to True?

string = 'REPTILE'[:3:]  
string = string[-1] + string[-2::-1]  
Choose two
Explanation

The resulting value is PER: slicing 'REPTILE' through index 3 produces REP, and the second expression moves its last character to the front while reversing the preceding characters. Therefore its length is 3, and 'P' < 'R' is true in lexicographic character comparison.

Community Discussion

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