Ask coding questions

← Back to all posts
0
Files
HarshPancake (0)

Ok I code for a school class and i wanted to make several projects in one repl but in different files but is that even posible because it only runs the code in the main.py

Answered by mat1 (2242) [earned 5 cycles]
View Answer
Commentshotnewtop
2
mat1 (2242)

You can use variables from other files by importing them. Example (if the other file is called otherfile.py):

import otherfile
print(otherfile.othervariable)

Make sure not to include the .py when importing.
Please mark this comment as the answer if it answered your question