Question: Python Pls Create a function called pre_ele. This function takes a list or string, puts it into p(callable) and if it finds the right value,
Python Pls
Create a function called pre_ele. This function takes a list or string, puts it into p(callable) and if it finds the right value, then it gets the value from num. The num means how many elements each list should be contained.
def pre_ele(*iterable, num: int, p: callabe):
#This function should be an iterative function, but do not import any stuff
#Do not create any helper function. The function should be 1.
#Enumulate function will not work please do as python iterative function
output Example:
first copy these function
def hide(iterable): for v in iterable: yield v
def nth(iterable, n): for i,v in enumerate(iterable,1): if i == n: return v return None
list(pre_ele('a.bcde.f.g.hijk',2,lambda x:x=='.'))-->[['a', '.'], ['e', '.'], ['f', '.'], ['g', '.']]
print(list(pre_ele(hide('ab.defghi.klmn.pqrst.vwz.z'),5,lambda x : x=='.')))-->[['a', 'b', '.'], ['f', 'g', 'h', 'i', '.'], ['k', 'l', 'm', 'n', '.'], ['q', 'r', 's', 't', '.'], ['.', 'v', 'w', 'z', '.']]
list(prev_n(hide([1,2,3,4,5,6,7,8,9]),3,lambda x : x%2==1))-->[[1], [1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]]
nth(prev_n(ints(),5,is_prime),10) --> [25, 26, 27, 28, 29]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
