Sort by

recency

|

1726 Discussions

|

  • + 0 comments

    if name == 'main': x = int(input()) y = int(input()) z = int(input()) n = int(input())

      ls = [[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(ls)
    
  • + 0 comments

    My python Code

    if __name__ == '__main__':
        x = int(input())
        y = int(input())
        z = int(input())
        n = int(input())
        
        liste = []
        for i in range(0,x+1):
            for j in range(0,y+1):
                for k in range(0,z+1):
                    if (i + j + k) != n:
                        liste.append([i,j,k])
                        
        print(liste)
    
  • + 0 comments

    List comprehension is a nested loop . we can create this in two ways

    the first way

    a = int(input()) b = int(input()) c = int(input()) n = int(input()) listt = [] for i in range(a+1): for j in range(b+1): for k in range(c+1): if i+j+k != n: listt.append([i,j,k])
    print(listt)

    the second way

    a = int(input()) b = int(input()) c = int(input()) n = int(input()) listt = [[i,j,k] for i in range(a+1)for j in range(b+1)for k in range(c+1)if (i+j+k) !=n]
    print(listt)

  • + 0 comments
    if __name__ == '__main__':
        x = int(input())
        y = int(input())
        z = int(input())
        n = int(input())
        l_x = range(x+1)
        l_y = range(y+1)
        l_z = range(z+1)
        
        return_list = [[a, b, c] for a in l_x for b in l_y for c in l_z if a+b+c != n]
        print(return_list)
    
  • + 0 comments

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