The problem was that code was only ever storing the most recent comparison result.
Imagine your string was: "aBc".
The first time through the loop, it sees 'a' is not upper-case, and sets code to be 'F'.
The second time, it sees 'B' is upper-case, and sets code to be 'T'.
The third time, it sees 'c' is lower-case, and sets code to be 'F'.
The final value of code is therefore 'F'.
If you used a debugger - or even just got your code to output some debugging information to stdout, you would have been able to see the changing value of code for yourself, and seen what was happening.