0

Calculating the index of an sub list acc to sum of all int elements of a list in Python

For a particular ques I have tried using different funcs to pop a sublist whose sum of all int elements of the sublist is not equal to n , here’s what I have tried using so far : What I’m getting stuck on is what logic to use to defence to the sublist with the wrong sum. Doesn’t work Help Code: from itertools import product x= int(input()) y= int(input()) z= int(input()) n= int(input()) lis= [x,y,z] prodman= list(product(list,list,list)) p_list= list(map(list,prodman) def funcman(): for p_maine in p_list: if (sum(p_maine) != n): ??????????????????????? else: continue print(p_list)

25th Nov 2020, 7:08 AM
Toy
2 Respostas
+ 4
Toy , to get a better understanding of your problem, it would be great getting 1 or 2 input samples and the resulting output from you. Thanks in advance!
25th Nov 2020, 10:28 AM
Lothar
Lothar - avatar
+ 1
product(list,list,list) what is it? list is the built-in function to convert something to list object. And I cant figure out what did you try to do if I got you correct this code could help you: https://code.sololearn.com/cSW9CEktFlLV/?ref=app
25th Nov 2020, 8:37 AM
Shadoff
Shadoff - avatar