0

I have written some code for a system, I have imported another file which stores all the information for login details. But when I go to test it and try to login it keeps coming up with "INCORRECT". Both of the code files are attached.

I have tried changing the names of the files, variables and changing the login details but it still doesn't work.

from database import user_data, pasw_data, no_file

name = user_data
code = pasw_data

def  user_check():
    user = input("USERNAME >>")
    if user == name:
        pasw_check()

    else:
        print("INCORRECT")

def pasw_check():
    pasw = input("PASSWORD >>")
    if pasw == code:
        print("ACCESS GRANTED")
user_check()

This is the file, which stores all the login info, named database.py

user_data = ["123"]
pasw_data = ["python"]
glhr
  • 4,439
  • 1
  • 15
  • 26

1 Answers1

1

You're checking a string (user) and a list (user_data) for equality. They aren't equal at all. The list just happens to contain a string that's equal to your query. You should use in to search lists (and strings, dictionaries, tuples, etc) for data:

if user in user_data:
    print("I'm in!")
ForceBru
  • 43,482
  • 10
  • 63
  • 98
  • thanks for replying so quick, this helped me alot, it works perfect thanks! –  Apr 20 '19 at 19:34