0
I have this code that works normally
def pdd(number, entrada):
for i, j, k, l, m in zip(entrada[:-1], entrada[1:], entrada[2:], entrada[3:], entrada[4:]):
if number in i:
print([j, k, l, m])
list_pad = [[1, 9], [1, 15], [1, 10], [1, 11], [1, 12], [1, 13], [1, 15], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18]]
pdd(15, list_pad)
Exit:
[[1, 10], [1, 11], [1, 12], [1, 13]]
[[1, 14], [1, 15], [1, 16], [1, 17]]
But instead of printing 4 records, I would like to be able to define the quantity per parameter.
Example:
pdd(15, list_pad, 6)
And you should leave:
[[1, 10], [1, 11], [1, 12], [1, 13], [1, 15], [1, 14]]
Or
pdd(15, list_pad, 2)
And get out:
[[1, 10], [1, 11]]
[[1, 14], [1, 15]]
[[1, 16], [1, 17]]
I could put examples of some calls of this function and what would be the expected result?
– Woss
@Andersoncarloswoss I reformulated my post, more summarized and with examples, see if you got it now.
– Suel
What exactly the function needs to do?
– Woss
Basically it will analyze the entry, which in this case is a list with small lists. Then analyze the input, and when identifying an item (list) that has the number passed by the parameter
number
, she will print the next 4 items (lists). This code already does, but I would like to be able to define the amount by a parameter passed to the function (instead of 4)– Suel
And if the list that has the value is the last?
– Woss
Then do not print, because after it there will not be the amount I set. The code already does this, it does not print if it does not meet the quantity. What I really wanted was to be able to define how many items (lists) to print, setting by parameter.
– Suel