Ask coding questions

← Back to all posts
how to run a specific file if you have multiple files
greatbilal1

Hi.
So I have my mian code on main.py and then when I create another file lets say main2.py and I try to run code in it--> it will run initial main.py instead

Ofcourse I can create new replit but I want to run and test snippets in the same tab

Voters
greatbilal1
Comments
hotnewtop
greatbilal1

it is not working ! I did what you both mentioned (I tired to add python as language and same resulg

CodingElf66

This is actually quite easy.

Create a file named .replit. Then, type the following into your code:

The part language = "python" is not needed, as it is already defined as the Repl language, so that part is unnecessary.

That's all, and hope you can mark it as answered!

WWEMONSTERMONST

You can run the file you want by using .replit file. Create a file with no name and extension .replit and use the following code.

It will execute the file you want, specified in file="".