Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list like this:

list = {0, 0, 0, 1, 1, 1}

I want to color all the 0's in red, but I dont want to count through all the elements, like in my solutions, which seems awefully complicated:

Table[If[list[[x]] == 0, Style[list[[x]], Red], list[[x]]], {x, 1, Length@list}]

How else could I do this without using Table? In other words, a simpler way, if possible.

share|improve this question
up vote 5 down vote accepted
list /. (0) :> Style[0, Red]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.