Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

login system user exist in textfile python

def loginExisting():
    userDataEntry = open('loginInfo.txt', 'r')
    listLines = userDataEntry.readlines()
    userDataEntry.close()

    userDict = {}

    for eachLine in listLines:
        entry = eachLine.split()
        username = entry[0]
        password = entry[1]
        userDict[username] = password

    checker = 0
    while(checker == 0):
        print("
You've registered already? (OwO) Okay then!
")
        usernameInput = input("Please enter your username:")
        passwordInput = input("Please enter your password:")


        if(usernameInput in userDict):
            if(userDict[usernameInput] == passwordInput):
                print("
Login successful!
Welcome back,", usernameInput)
                checker = 1

            else:
                print("Password is incorrect. Try again.")
                checker = 0

        else:
            print("Username does not exist. Try again.")
            checker = 0

    nextStep = int(input("
Would you like to:
1.) Exit
2.) Log out and return to menu

"))
    if(nextStep == 1):
        print("
Goodbye!")

    if(nextStep == 2):
        print("
Returning to menu...
")

        return nextStep
Comment

PREVIOUS NEXT
Code Example
Python :: how to assign a value to a key dictionary in a list python 
Python :: tusha 
Python :: how to find largest number in list python without max 
Python :: python program to multiply two numbers and multiply the answer with 2nd variables 
Python :: python delete directory even if not empty 
Python :: count upercase 
Python :: tensorboard dev upload in background colab 
Python :: While importing we detected an older version of numpy in 
Python :: jupyter notebook do not show matplotlib text above plot 
Python :: alexa in python 
Python :: how to set time limit for receiving data in socket python 
Python :: edit packet in scapy 
Python :: python tf.maximum 
Python :: snap pdf 
Python :: how to read comment before the root element of xml python 
Python :: fibonacci series stackoverflow 
Python :: build the .pyx file to c and run on python 
Python :: python loop increment by 2 
Python :: python for infinite range 
Python :: matplotlib add abline 
Python :: normalize a distribution plot 
Python :: Python Tkinter Scale Widget Syntax 
Python :: design patterns python - restrict what methods of the wrapped class to expose 
Python :: get out of a help screen python 
Python :: django not configured pylint error fix 
Python :: while except python 
Python :: Problem With This? 
Python :: json object type in python 
Python :: giving activation in dense layer keras 
Python :: how to use kite python 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =