hackerrank---List Comprehensions

题目链接

刷刷Python基本功...列表解析

附上代码:

1 x = int(input()) 2 y = int(input()) 3 z = int(input()) 4 n = int(input()) 5 print [[i, j, k] for i in xrange(x+1) for j in xrange(y+1) for k in xrange(z+1) if i+j+k != n]

 

你可能感兴趣的:(list)