Hi I’ve been using replit for my python and c language on iPad app.
I have encountered that i can only execute one code which is from the file of main.c or main.py
And all the other files having code written in it couldn’t be executed and the console executes just the main file, this is causing a problem to me as i have to copy and paste the code in main file every time i wanna see the output.
Anyone out there please help me with this, thanks.
Hi @adluriajithkuma this is the way that Repl templates are set up. By default the “run” button starts with main.py
(for the Python template).
There are lots of ways to make the run button load a different Python file instead. A quick and easy way is to use main.py
as a redirect. For example:
In main.py have the following code:
import filename
where filename is the name of the Python file you want to run, minus the .py
section.
Let me know if this solves your issue.
@adluriajithkuma If you want other files to run, and not the main file, change a few things in the .replit file, but that’s complicated.
If you edit the .replit file, you can change a Repl’s Run command.
Docs: https://docs.replit.com/programming-ide/configuring-repl
Hi. You can run the C files using the console screen. make filename
command compiles the file. The file can then be executed with the “./filename” command (no extension in file names).
Python files can also be run with the command python filename.py
If the files are in a folder other than the main directory, the directory must first be changed (e.g. cd project1
)