fork download
  1. # your code goes here
  2.  
  3.  
  4. target=3
  5. n=5
  6.  
  7. dp = [[-1]*(target+2)]*(n+1)
  8. print(dp)
  9. print(type(dp))
  10. dp = [[-1] * (target+2) for _ in range(n+1)]
  11. print(dp)
  12. print(type(dp))
Success #stdin #stdout 0.02s 9044KB
stdin
Standard input is empty
stdout
[[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]
<class 'list'>
[[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]
<class 'list'>