what can cause red stool or black stool

Black or red stools that aren’t caused by orange, purple, or red foods can indicate internal bleeding somewhere in the gastrointestinal tract. Stool that contains blood from the upper digestive tract is black, tarry, has a distinctive odor, and is known as melena. Stool that is red because it contains blood that typically comes from further down the digestive tract is called hematochezia. In the case of hematochezia, the blood may coat the stool, be mixed in with the stool, or even be passed by itself without any stool at all.

Potential causes of black stools include:

medical conditions causing bleeding that results in acidified blood (blood from higher in the digestive tract)
iron supplements or foods high in iron
Pepto-Bismol or other medicines containing bismuth
eating foods such as black licorice, blueberries, and large amounts of spinach or other greens
other foods dark in color

Potential causes of red stools include:

medical conditions causing bleeding (such as from hemorrhoids, anal fissures, or diverticular disease)
food containing artificial red coloring such as red gelatin or popsicles 
naturally red foods such as tomato juice or soup or large amounts beets