@@Cloudxxx23 because if x = 2, we can take 0,1,2. And range always takes 1 less value, so if we don't put +1 and take range (2), it will give only 0 and 1.
Bro, they have clearly mentioned to not solve using this method. You haven't spoken about List Comprehensions at all. Just add a rick roll somewhere to this video.
full_liste = [[a,b,c] for a in range(x+1) for b in range(y+1) for c in range(z+1)] new_full_liste = [] for liste_name in full_liste : if reduce(lambda a,b: a + b , liste_name ) != n : new_full_liste.append(liste_name) print(new_full_liste) #do not forget to import reduce from functools
x=int(input('enter the value of x')) y=int(input('enter the value of y')) z=int(input('enter the value of z')) n=int(input('enter the value of n')) list=[[a,b,c] for a in range(x+1) for b in range(y+1) for c in range(z+1) ] list1=[[a,b,c] if a+b+c==n else [] for a in range(x+1) for b in range(y+1) for c in range(z+1)] i=0 while i
Hi everyone please try this one, this solution is using list comprehension and this will work for you 100%: l = [[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(l)