Login (simple version)

Very simple login script - requires a 'csv' file with usernames and passwords and the 'csv.py' module. Note that this script uses no security! All the usernames and passwords are stored in plain-text in the csv file. Neither does it give you more than one chance to login, but it's not that difficult to break.

import sys # Built into Python - controls operating system functions.
import csv # This is my CSV library, not Pythons - it needs to be in the same folder.

loggedin = False
users = csv.csv2sequence('users.csv') # This file must be in the same folder

username = input('Enter username : ')
password = input('Enter password : ')

for user in users:
    if username == user[0] and password == user[1]:
        loggedin = True

if loggedin:
   print('Success - you are logged in as \'{0}\'.'.format(username))
   print('Incorrect username or password.')

# Rest of program goes here ...

print('This is the rest of the program ...')

I've provided a copy of this Python script, the csv.py library and the users.csv file containing the sample usernames and passwords. Fill your boots.
Mark Mills,
18 Apr 2020, 14:03
Mark Mills,
18 Apr 2020, 14:10
Mark Mills,
18 Apr 2020, 14:04