Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

how to run a specific file if you have multiple files

greatbilal1
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

1 year ago

Voters

Comments

TopNew
3
WWEMONSTERMONST
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.

run = "your file name" language = "python"

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

1 year ago
2
greatbilal1
greatbilal1

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

image

1 year ago
2
CodingElf66
CodingElf66

This is actually quite easy.

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

run = "main2.py"

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!

1 year ago
Load more