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