Ask coding questions

← Back to all posts
How to connect and link two files together using python?
Matt1101 (0)

I'm trying to create a game but I do not know how to link two files together. Example: if I have two files, one named and the other named, how can I link the two files together by using both piles to get the result from and

Answered by ch1ck3n (2335) [earned 5 cycles]
View Answer
ch1ck3n (2335)

import test



mylittletest = "hello"

when I do import test it imports and every function and variable!

and yes it does run both files so if I put print("bababooey") on both files it would print bababooey twice.

Matt1101 (0)

@ch1ck3n wait for some reason on a replit file I created named help, when I connect the two files together, it doesn't connect the functions or the imports such as import pygame?

ch1ck3n (2335)

@Matt1101 try renaming the file to something random

Matt1101 (0)

@ch1ck3n Still it doesn't work

ch1ck3n (2335)

@Matt1101 hmmm can you invite me to the repl

Matt1101 (0)

@ch1ck3n Actually someone commented on the help file and the code worked, Thanks for helping.