Create a Python file in terminal

You can create a Python file directly from the terminal. Follow these steps to do it:

  1. Open Command Prompt (cmd).
  2. Open the Python interpreter by typing python inside the terminal.
  1. Open (or create if it doesn’t exist) a new file for writing inside an existing directory.
  1. The file is created. Now, you can write to it. Create a loop:
  1. Add a text you want to repeat. Remember to add an indentation at the beginning.
  1. It’s a good practice to close the file after the process:

The full code: