What does the function split do? Explain with an example.
def split(L, first):
return [b for b in L if b <= first], [b for b in L if b > first]
Please find below explanation and don't forget to give a Like.
Explanation:
l=[10,20,30,40,50] first=35
consider above list and first number.
The above code will produce the two lists
first list contains elements that are less than equal to first
second list contains elements that are greater than first
[10,20,30] [40,50] this will be the result.
If first number is present in L then the first number will be included in the first list of the result check the other output.
Output:
2nd output:
Get Answers For Free
Most questions answered within 1 hours.