Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

1 Answer 1

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.