This is my first program that I wrote on my own. Is there something I can improve upon?
There are a few things that still need to be added, such as:
- Confirm password while registering
- Adding a way to get the forgotten password using the email ID
But its functionality is minimally complete. Are there any things which professionals see that I can improve or change in this program?
Main File
import Functions
start = ""
while start == "" :
start = input("Type S to Create a Account and Type L to login into your Account: ")
Username_List = Functions.username_list()
if start == "S" or start == "s":
username = input("Enter a Username: ")
for user in Username_List:
while user == username:
username = input("Username Exists, Try Again: ")
password = input("Enter a Password: ")
email_adress = input("Enter Email ID: ")
Functions.sign_up(username,password,email_adress)
start = ""
elif start == "L" or start == "l":
login_username = input("Enter Your Username: ")
while login_username not in Username_List:
print('Username Does not Exist.')
user_input = input("Type R to retry and X to exit: ")
if user_input == "r" or user_input == "R":
login_username = input("Enter Your Username: ")
if user_input == "x" or user_input == "X":
break
if login_username not in Username_List:
print("Invalid Session \n\n")
start = ""
else:
no = Username_List.index(login_username)
password = input("Enter a Password: ")
Functions.extract_matrix(login_username,password,no)
start = ""
else:
print("Invalid Session \n\n")
start = ""
Functions.py
import csv
def sign_up(username,password,email):
filename = "signup_info.csv"
data = [[username,password,email]]
# writing to csv file
with open(filename, 'a', newline='') as csvfile:
# creating a csv dict writer object
writer = csv.writer(csvfile)
# writing data rows
writer.writerows(data)
def username_list():
username_list=[]
with open('signup_info.csv','r') as f:
for line in f :
username_list.append(line.split(',')[0])
return username_list
def extract_matrix(username,password,no):
password_list = []
email_list = []
username_list = []
with open('signup_info.csv','r') as f:
for line in f:
password_list.append(line.split(',')[1])
for line in f:
email_list.append(line.split(',')[2])
for line in f:
username_list.append(line.split(',')[0])
data_password = password_list[no]
while password != data_password:
print('Incorrect Password')
user_input = input ("Type R to retry and X to exit: ")
if user_input == "r" or user_input == "R":
password = input("Enter Password: ")
if user_input == "x" or user_input == "X":
break
if password == data_password:
print("Login Successful")
else:
print("Invalid Session \n\n")