Dice game login system The end result of this is to allow a user to log in and/or register themselves for a dice game. Please post some suggestions for improvement.

import pickle

logged_in = False

with open('users.pickle', 'rb') as a_file:
    users = pickle.load(a_file)

login_or_signup = input('do you want to login or signup? ')

# sign up (creating new account)
if login_or_signup.lower() == "signup":

    create_username = input("enter a new username: ")
    create_password = input("enter a new password (Your password cannot be the same as your username !!!!!!!): ")

    if create_password in users:
        create_password = input("password taken re-enter: ")

    users[create_username] = create_password

username = input('please enter username: ')

if username in users:
    password = input("enter password: ")
    if password == users[username]:
        print("access granted")
        logged_in = True

else:
    print("access denied")

with open("users.pickle", 'wb') as f:
    pickle.dump(users, f, pickle.HIGHEST_PROTOCOL)
You are introducing this requirement of not having a password being the same as a username, but the problem is the way you check for it:

create_password = input("enter a new password (Your password cannot be the same as your username !!!!!!!): ")

if create_password in users:


The problem arises when my password matches someone else's username.

I think you meant to just compare create_username with create_password values.



In general, there is rarely a case when you should try writing your own login system except that for learning purposes. You may though improve your current setup by introducing hashing of the passwords, to avoid storing them in plain text: Salt and hash a password in python; as well as more password strength requirements: Checking the strength of a password.