The answer is D: red square.

The rule
The pattern repeats every 4 things: red triangle, red square, red triangle, red star. Then it starts again from the beginning.
The pattern as Python code
Here is a tiny Python program that follows the same rule. Type it into IDLE and run it to print the whole pattern, including the answer.
pattern = ["red triangle", "red square", "red triangle", "red star"]
for position in range(10):
print(position + 1, pattern[position % len(pattern)])
When you run it, Python prints:
1 red triangle 2 red square 3 red triangle 4 red star 5 red triangle 6 red square 7 red triangle 8 red star 9 red triangle 10 red square
Pixel says: Try changing a number in the code and run it again. Can you make the pattern go on for 20 steps? Meow!