Skip to content
Permalink
Browse files
Update and rename text.py to account.py
  • Loading branch information
morarul committed Nov 12, 2019
1 parent c81a40c commit 6981134e29c105c2b626b5286eb859930957b27c
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 25 deletions.
@@ -0,0 +1,152 @@
users= [ ]

def read_users():
return users
def write_users(list):
users = list
#take from keyboard values for username, email and password, the type of account will be censored
def request_registration_user():
username = input("To register, enter username: ")
email = input("Enter email: ")
password = input("Enter password: ")
process_user_registration(username, email, password)
display("Your censored account has been created.")
#take from keyboard values for username, email and password, the type of account will be uncensored
def request_registration_uncensor():
username = input("To register, enter username: ")
email = input("Enter email: ")
password = input("Enter password: ")
process_uncensor_registration(username, email, password)
display("Well done boy, welcome to the team!")
#choose the type of the account
def request_chosing_type():
response = input("You want a censored account? Y/N: ")
if response is 'Y':
request_registration_user()
elif response is 'N':
request_registration_uncensor()
else:
display("That's not an answer!")
#function for printing
def display(result):
print(result)
#function for login
def request_login():
username = input("To log in, enter your username:")
pwd = input("Enter your password: ")
empty = {}
data = process_login(username, pwd)
if data != empty:
display("Welcome back son! You are logged in. :)")
return data
else:
display("Please create an account first! ")
return empty
#changing the password of the actual account(logged)
def request_password_change(data):
response = input("Do you want to change your password? Y/N: ")
if response is 'Y':
pwd = input("Enter your password:")
process_password_update(data, pwd)
display("Your password has been updated.")
else:
display("Thank you!")
#changing the email of the actual account
def request_email_change(data):
response = input("You want to change your email? Y/N: ")
if response is "Y":
mail = input("Enter your new email:")
process_email_update(data, mail)
display("Your email has been updated.")
else:
display("Thank you!")
#changing the username of the actual account
def request_username_change(data):
response = input("Do you want to change your username? Y/N: ")
if response is "Y":
u_name = input("Enter your new username:")
process_username_update(data, u_name)
display("Your username has been updated.")
else:
display("Thanks you!")
#delete your account from the dictionary
def request_user_removal(data):
response = input("Do you want to remove your account? Y/N: ")
if response is "Y":
process_user_removal(data)
display("You have been removed from the community. :(")
else:
display("Wise choice!")
# empty list
users= []

# empty dictionary
user_data = {}
def upload_users_list(list):
users = list
#to register a new censored user
def process_user_registration(u_name, the_email, pwd):
user_data['username'] = u_name
user_data['email'] = the_email
user_data['password'] = pwd
user_data['type'] = 'censored'
users.append(user_data)
#to register a new uncensored user
def process_uncensor_registration(u_name, the_email, pwd):
user_data['username'] = u_name
user_data['email'] = the_email
user_data['password'] = pwd
user_data['type']= 'uncensored'
users.append(user_data)
def get_users():
return users

#shows the details of the actual(logged) account
def display_users(data):
print("Do you want to see the users?")
ans=input("Y/N: ")
if ans=='Y':
print(data)

#test if your username and password exist in the dictionary
def process_login(u_name, pwd):
user= {}
found = False
count = 0

while found is False and count < len(users):
data = users[count]
if data['username'] == u_name and data['password']==pwd:
found = True
user = data
count = count+1
return user
#change your password
def process_password_update(data, pwd):
data['password'] == pwd
#change your email
def process_email_update(data, mail):
data['email']==mail
#change your username
def process_username_update(data, u_name):
data['username']==u_name
#delete your account
def process_user_removal(data):
del data

#the functions are for running and testing, creating an account, loggin into the account and then amending the details of the account.
if __name__ == '__main__':
list = read_users()
upload_users_list(list)
request_chosing_type()
write_users(get_users())

data = request_login()
empty = {}
if data != empty:
request_username_change(data)
request_password_change(data)
request_email_change(data)
request_user_removal(data)
if __name__=='__main__':
display_users(data)
25 text.py

This file was deleted.

1 comment on commit 6981134

@morarul
Copy link
Owner Author

@morarul morarul commented on 6981134 Nov 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished the code

Please sign in to comment.