Where to Write Your Code
Sadly, code can't be written in a Microsoft Word document. Well… I guess it can, but if you do, the full force of Reddit will come personally to your house and put you out of your misery.
You could write your code in a text editor or in an integrated development environment (IDE). While a text editor offers some useful tools like syntax highlighting and automatic indentation, an IDE typically has a lot more features (including really good tools to help you find errors in your code).
Integrated Development Environments
IDEs are editors with many extra utilities to help in programming. There are many to choose from, but a great IDE to start with is Visual Studio Code, or VSCode for short. Through plugins, VSCode has great support for a multitude of languages.