Ask coding questions

← Back to all posts
Why I can't run my second file
AshkiKudzma (5)

I want to run my second python file but it always run whatever i have in but not in second file i made.

AliBaba1 (5)

To do this
go to your file
and write the following code in it

from filename import *

Remember replace filename in code with your desired filename to be run
Note: do not use keywords as your filenames.

paulfears (60)

that is because multible files are designed to be object oriented
you can run the other file by turning it into a class or function and importing it with the import command

or you could add this to

import os

timmy_i_chen (960)

Here's an example of using multiple files in python: