Python Programming - Data Types - Discussion
Discussion Forum : Data Types - General Questions (Q.No. 62)
62.
What is the output of the following code snippet?
my_string = "Hello, World!"
result = my_string.split()
print(result)
Answer: Option
Explanation:
The split()
method in Python splits a string into a list of substrings based on a specified separator. If no separator is provided, it defaults to splitting the string by "whitespace".
In this case, since no separator is provided, the string my_string
will be split into substrings based on whitespace, resulting in ['Hello,', 'World!']
, which will be printed.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers