Well done writing that code :) To actually play the game on your computer you need to run the Python file you just created.
Note: If you built the game using repl.it you only need to press "Run". Nevertheless, read through this section and come back to give it a try once you have Python installed on your system.
Run Python Scripts on Different Operating Systems
Depending on your operating system, the process for running your code on Python may differ. Below are instructions for macOS, Linux and windows.
Run Python Scripts on macOS
To run your Python code on macOS, open up your Terminal. Press Cmd+Space to open up Spotlight, and type Terminal, then press Enter:
This opens up the Terminal program on MacOS, which allows you to run Python programs.
Run Python Scripts on Linux
The process is very similar on Linux, where you can open your Show Applications menu by pressing the button on the bottom left of your dock, then type Terminal into the search bar:
This will open up the Terminal program on many Linux distributions. If you're working on Linux, you're likely already familiar with your terminal.
Run Python Scripts on Windows
On Windows, you will need to open up a PowerShell window.
Info: The process on Windows works a little bit differently than on UNIX-based systems such as Linux and MacOS. Read over the official tutorial for setup instructions, check Discord, or stick with running the script on repl.it or something similar for now.
Make sure your Terminal program is open. You'll get to know it in more detail down the road. For now, just type the suggested commands and keep going. Start by navigating to your Desktop:
cd ~/Desktop
It will look similar to the screenshot below on your computer:
Info: Your terminal surface and colors will probably look different than what you see here. There are a million different implementations and designs, but the functionality will be the same. So no worries if it looks different, as long as it works the same.
Typing this command will teleport you to your Desktop, where you saved the file guess.py earlier on:
Run the Script
Now it's finally time to play your own guess-the-number game. Since you wrote it in Python, you need to also start it using the command called python:
python guess.py
Note: In the video you will see that I use the python3 command. On Ubuntu Linux, you may need to use that instead of just python. You will install Python 3 later. On macOS, I suggest to just run your game with the built-in python command.
And lo and behold! Here you are! Ready to play your game:
Type in your best guess and give your game a thorough test run. It should work the same as the game you played in the previous lesson in the online playground.
If you want to play again after you finish the game, you just need to press the up arrow ↑ once and your terminal will provide you with the most recent command:
python guess.py
Pressing Enter will start the program again from the beginning.
After you've exhausted your tolerance for guessing numbers, you can move on to the next lesson. There, you'll get a high-level overview of all the different parts of the Python language that you've used to build this game.