fork download
  1. # your code goes here
  2. l=[[1, 2, 3], [4, 5, 6], [7, 9, 9]]
  3. replacer=iter([1,5])
  4.  
  5. l=[[item if item!=9 else next(replacer) for item in group] for group in l]
  6.  
  7. print l
  8. #l配列の9を1に置き換えたい
  9. #l配列の9を5に置き換えたい
  10. #l[2][1]を1にl[2][2]を5に置き換えて
Success #stdin #stdout 0.01s 23336KB
stdin
Standard input is empty
stdout
[[1, 2, 3], [4, 5, 6], [7, 1, 5]]