I'm new to Python and I wrote a function:
def f(x, y, z):
ret = []
for i in range(x):
for j in range(y):
for k in range(z):
ret.append((i, j, k))
return ret
print f(2, 3, 4)
Output:
[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 1, 3), (0, 2, 0), (0, 2, 1), (0, 2, 2), (0, 2, 3), (1, 0, 0), (1, 0, 1), (1, 0, 2), (1, 0, 3), (1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 2, 3)]
But I'm not satisfied with that because I think there must be a shorter implementation.
So could any one give me some hint about that?