QuestionQ96

VerifiedStrings

What behavior should be expected from this code?

the_string = ',,'.join(('alpha', 'omega'))  
the_list = the_string.split(',')  
print(',' in the_list)  
Explanation

Joining the two strings with ',,' creates alpha,,omega. Splitting on a single comma yields the list ['alpha', '', 'omega']; because no list element equals ',', the membership test evaluates to False.

Community Discussion

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