I am sure there are a hundred other solutions, but this one does the job and should be reasonably efficient: ``` In: Map[If[ListQ[#], #, Replace[#, 0 -> 1]] &, {{0, 0}, 0}] Out: {{0,0},1} ``` Another better solution: ``` In: Replace[{{0, 0}, 0, 0, 0, {0, 0, 0}, {{0, 0}, 0}, 0, 0}, 0 -> 1, 1] Out: {{0, 0}, 1, 1, 1, {0, 0, 0}, {{0, 0}, 0}, 1, 1} ``` The final '1' in the Replace[] expression indicates the level to act on. If you change it to '2' you instead get: ``` In: Replace[{{0, 0}, 0, 0, 0, {0, 0, 0}, {{0, 0}, 0}, 0, 0}, 0 -> 1, 2] Out: {{1, 1}, 1, 1, 1, {1, 1, 1}, {{0, 0}, 1}, 1, 1} ```