Ask coding questions

← Back to all posts
files
ryanrwatkins (0)

This is pretty basic, but how do you run code in files outside of "main.py"? Maybe I am not seeing something. Thx

Answered by mwilki7 (260) [earned 5 cycles]
View Answer
Commentshotnewtop
mwilki7 (260)

say your other file is called code.py
do: import code

say your code.py file has a function called add(a, b)
if you want to call it do:
code.add(a,b)

ryanrwatkins (0)

@mwilki7 Thanks, I figured that it was something easy I was missing. I kept adding .py to the end on the import. Thx!