QuestionQ127

VerifiedStrings

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

string = 'SKY'[::-1]  
string = string[-1]  
Choose two
Explanation

The final value of string is 'S': reversing 'SKY' yields 'YKS', and index -1 selects its final character. A one-character string has length 1, and its first and last character references both return that same character.

Community Discussion

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