Error message when users run project about missing environment variables

Problem description:

when I run my login project it gives me error “key error: password”

code 

import os
import time
password = os.environ['password']
hack_code = os.environ['hack code']
password_entry = ""
while True:
  password_entry = input("enter password: ")
  if password_entry == password:
    print("hack code is " + hack_code)
  else:
    print("invalied password")
    time.sleep(15.6)

project link
[https://replit.com/@LevKnettle/my-first-login-code?v=1]

Browser/OS/Device:

Have you set the environment variables?
If not check out this link:
https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables

1 Like

I’ve moved this to #code-help:python as it isn’t a bug.

2 Likes

I added the environment variables in

I see you are attempting to make “global environmental variables.” These were taken out of replit (that is, .env files have been deprecated). There is currently no way to have public environmental variables, though you could submit a ticket. I suggest you look into encrypting your environmental variables.

Using secrets you can create environment variables which you can access within your code (as this user has done), however you cannot create them in code or use a .env file.

Your Problem Solved ?

so what should I do because i am confused by the term “encrypt” to i import a encrytion libary

um yes that is what I would recommend