We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

# List Comprehensions

# List Comprehensions

+ 0 comments `# easy one liner#python#list`

l1 = [ [i,j,k] for i in range(x+1) for j in range(y+1) for k in range(z+1) if i+j+k!=n] print(l1)

+ 0 comments reselt = [] for i in range(x + 1): for a in range(y + 1): for z in range(z + 1): if i + a + z != n: reselt.append([i, a, z]) print(reselt)

+ 0 comments from itertools import product l = [x,y,z] y = [] for i in range(max(l) + 1): y.append(i) m = list(product(y,repeat = 3)) k = [i for i in m if i[0] <= l[0] and i[1] <= l[1] and i[2] <= l[2] and sum(i) != n] p = [] for j in k: if j not in p and list(j) not in p: p.append(list(j)) print(p)

+ 1 comment if

**name**== '**main**': x = int(input()) y = int(input()) z = int(input()) n = int(input())if x+y+z != n: for i in range(x+1): for j in range (y+1): for k in range(z+1): print (f"[{i},{j},{k}]"+",",end="")

+ 0 comments What's the purpose of solving the challenge by yourself if you just have to copy paste other's code? and some of the dudes are sharing it

Load more conversations

Sort 1094 Discussions, By:

Please Login in order to post a comment