fork download
  1. f = [[1, 'nan'], [2, 'nan', 'nan'], [1, 3]]
  2. ef = []
  3.  
  4. for x in f:
  5. found = False
  6. for pos, e in enumerate(x):
  7. if e == 'nan':
  8. x[pos] = 1
  9. found = True
  10. ef.append(1 if found else 0)
  11.  
  12. print f, ef
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
[[1, 1], [2, 1, 1], [1, 3]] [1, 1, 0]