CodePudding user response:
The problem is that you have 3 if blocks in a row, and you are expecting them to behave like elifs.
When ops[i] is 'C', it enters the first if block, and then, because 'C' != ' ', it enters the else block at the end.

