I have 2 python repls: Login authentication, and a hangman game.
Once a user has successfully logged in and confirm that he wants to play, Is there a way that my hangman game will run automatically? I’ve been googling, but cant find the right answer
Repl link: https://replit.com/@QBrd1/ProjectLoginWithHash#main.py
##insert game here
##--how to add---https://replit.com/@QBrd1/Hangman
I don’t know of a way to link two Python Repls. You can make Repl A into a PyPi package and Repl B import the package but that is complicated and would not be effective.
I’m still starting out, and doesnt know enough of Py and making a package. I might just delete it then. Thanks though!
You could put two Py files in one Repl if you wanted. That is easy to do.
# File "other.py"
# File "main.py"
from other import fun
What am i doing wrong?
#rest of the code
#main Py file
import os, random, time
from replit import db
from Hangman.py import game
The code in
def game(): is not indented. Python is whitespace sensitive. I looked at your code, and you have two functions called
Hangman.py. Try deleting line 1. That should do the trick.
Done. I changed the subroutine game() to fun() and indented all code below it.
But do i have to install something? Its throwing me another one.
Change the import to just
Hangman instead of
Let’s use your import for these examples.
When you include the
. in the import name, python tries to import the requested import from one of two places:
- (Higher priority) From a file with the name
Hangman it tries to find
py, then import
- (Lower priority) From a folder called
Hangman it tries to find a file called
py.py, then import
fun from that.
Thank you for pointing it out, and explaining it in detail!
hold on @CoderElijah @Firepup650 this was a school assignment and the thing he needed to do was make separate files for import ;-;
We didn’t know that until just now.
I know but I probably should have asked xD also we should have asked for the repl link because it was really hard to do it without it
@AshWinters Please mark this as solved if we solved your problem and please don’t let people give you the answers to school assignments. We are only allowed to point you in the right direction.
oh I’m dumb I can’t read sorry
Preferably, mark whichever post you found the most helpful as the solution.
Is it an issue that its for my assignment?
No worries! Thanks either way!
yes it is an issue that it is for the assignemnt
It should have been at least mentioned, because we are only allowed to give hints as to how to resolve your problems when it is assignments.