Two ways to do that:
Option 1: In the text editor, click the code button, circled in red here:

Option 2: Sandwich your code between backtick symbols `
either end. The backtick symbol (found right below escape key) signals the program to switch to code mode. If you use three in a row ```
, you can put in a block of code, with multiple lines.