Oct-08-2019, 09:53 AM
Hi,
I don't understand why this code that I have write didn't work:
Ravcoder
I don't understand why this code that I have write didn't work:
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) new_list =[ [a,b,c] for a in range (0,x +1) for b in range (0,y +1) for c in (0,z +1) if a+b+c != n] print(new_list)Result :
[[0, 0, 0], [0, 1, 0], [0, 1, 2], [1, 0, 0], [1, 0, 2], [1, 1, 2]]Correct result:
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]Regards,
Ravcoder