I'm trying to set up a login procedure. Here's what I'm trying:
import users
import sys
print()
print("Please enter your username.")
print()
username = input(">")
if username not in users.usrlist:
print()
print('User does not exist.')
sys.exit()
else:
user = users.username
print()
print('Please enter your password. Note that for security reasons, nothing will appear as you type.')
print()
pw = getpass.getpass(">")
if pw == user['password']:
print()
print('Welcome, ' + user['name'] + '.')
print()
else:
print()
print('Incorrect password.')
sys.exit()
The bit that isn't working is the "user = users.username" bit. I'm guessing it's trying to look for the entry "username" in the users.py file instead of changing the literal string "username" to the value of the user-input username. Is there a way to append whatever the user inputs to the end of "users." so that if the user enters, for instance, "Bob", it will look for "users.Bob"?