+ 1

How the python interpreter thinks for the folllowing code?

https://www.hackerrank.com/challenges/list-comprehensions/problem x, y , z, n = int(input()), int(input()), int(input()), int(input()) 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])

29th Mar 2019, 12:05 PM
Ashutosh Dash
Ashutosh Dash - avatar
2 Respostas
+ 6
[[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] is same as for i in range(x+1): for j in range(y+1): for k in range(z+1): if i+j+k != n: myList.append([i,j,k]) considering myList as the list containing lists of [a,b,c].
29th Mar 2019, 1:14 PM
Шащи Ранжан
Шащи Ранжан - avatar