Ask coding questions

← Back to all posts
Can't seem to run multiple python files in one project
sodalover (8)

I have two .py files in my project. The first file, ran 100% fine. I added a second file,, which only has print('hello') in it. When I switch the file viewer to, clicked run, and the console only displays the output of, but does not display 'hello'. Why can't I get 'hello' to show up?

Answered by Geocube101 (528) [earned 5 cycles]
View Answer
Geocube101 (528)

The replit editor only runs the main file. In order to run the second file, you will have to import it import [file_name]. When importing another python file, do not include the .py extension.
Note: The file runs immediately after import meaning that as soon as the file imports, it runs. If you need the file to only run at a specified line, that is where you put the import command.

sodalover (8)

@Geocube101 Do you know if there a reason for this limitation? I don't think I ran into this problem when I last used a standalone IDE.

Geocube101 (528)

@sodalover I do not know the reason.

ash15khng (507)

@Geocube101 @sodalover needs to have a builtin "run point" (I'm not sure what the proper word is) to run your repl, so it always finds and runs it. This is also why you cannot rename