I am trying to make a password script in python that makes it so that if you insert the right password then it turns passwordAccepted to 1 and the other script would work.
Variables.py
passwordAccepted = 0
Password.py
import Variables
password = "" #Enter your password
userInput = input("What is your password?\n")
if userInput == password:
print("Access Granted")
Variables.passwordAccepted = 1
else:
print("Access Denied")
Variables.passwordAccepted = 0
Player.py
from Variables import passwordAccepted
class Player:
Inventory = []
Level = 1
if passwordAccepted == 1:
option = input("What do you want to see?\n1. Inventory\n2. Level\n\n")
if option == "Inventory":
print("\nYou have:")
for x in Player().Inventory:
print(x)
elif option == "Level":
print("\nYou are level", Player().Level)
else:
print("Either type in \"Inventory\" or type in \"Level\"")
I am also new to python but tried using from to import only the variable and tried to import the variable from Variable.py to Password.py and then to Player.py.