I was currently trying to solve this challenge - List Comprehensions - and came up with this solution in python3:
if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input())
list = []
for a in range(0, x+1):
for b in range(0, y+1):
for c in range(0, z+1):
if a + b + c != n:
list.append([a, b, c])
print(list)
But what's Bothering me is this one liner solution that I found in discussion:
x, y, z, n = (int(input()) for _ in range(4))
print ([[a,b,c] for a in range(x+1) for b in range(y+1) for c in range(z+1) if a + b + c != n ])
I'm a complete beginner and don't know if this one liner is permittable to use and if permittable, can you please explain how this one liner works? Can you share any source from where I can start learning how to use such one liner codes?