QuestionQ25

VerifiedStrings

What behavior is expected from the following code?

the_list = "alpha;beta;gamma".split(";")  
the_string = ''.join(the_list)  
print(the_string.isalpha())  
Explanation

split(";") removes the semicolons by separating the text into alphabetic substrings, and ''.join(the_list) concatenates those substrings without separators. The resulting string, "alphabetagamma", consists solely of alphabetic characters, so isalpha() returns True.

Community Discussion

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