How many elements will the list1 list contain after execution of the following snippet?
How many elements will the list1 list contain after execution of the following snippet?
The split() method in Python divides a string into a list using a specified separator. In this case, the string "don't think twice, do it!" is split using a comma (',') as the separator. This results in two parts: "don't think twice" and " do it!", which become the elements of the list. Hence, the list1 will contain two elements after executing the given code snippet.
There will be two elements, the answer should be A
correct answer is A almost 20% answers are wrong on this site
this is wrong
list="don't think twice, do it!".split(',') print(len(list)) output===>2
List1 = "don't think twice, do it!".split(',') print(List1) ["don't think twice", ' do it!'] correct answer is A which is two
string.split(separator, maxsplit) separator : Optional. Specifies the separator to use when splitting the string. By default any whitespace is a separator maxsplit : Optional. Specifies how many splits to do. Default value is -1, which is "all occurrences"
Actually list1 doesnt exist, the definition is List1.
Answer should be A
It prints ['don't think twice', ' do it!']
answer: A. two
Answer should be A
A is correct.
2 elements