Skip to content

Commit

Permalink
Wrapped everything in a main function
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmyMwaura committed Feb 20, 2022
1 parent 2ed5292 commit 9f54ab1
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 71 deletions.
145 changes: 76 additions & 69 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,85 +1,92 @@
from user import User
# from math import random
import random
import string

choice = ''
while choice != '1' or choice != '2' or choice != '3':
choice = input('Would you like to create an account or Login?'
'\n1. Create an account'
'\n2. Login to existing account'
'\n3. Exit'
'\n '
)
def main():
greetings=['Hey', 'Hi', 'Wassup', 'Jambo']
choice = ''
while choice != '1' or choice != '2' or choice != '3':
choice = input('Would you like to create an account or Login?'
'\n1. Create an account'
'\n2. Login to existing account'
'\n3. Exit'
'\n '
)

if choice == '1':
"""
Account creation
"""
if choice == '1':
"""
Account creation
"""
def random_password(length=4):
char_set = string.ascii_letters
return str(random.randint(1000,9999)) + ''.join(random.choice(char_set)for _ in range(length))

def confirm_account_creation():
global repeat
def confirm_account_creation():
global repeat

if okay == 'OK':
user = User(user_name, password)
User.save_user(user)
print('Account created, proceed to Login\n')
# print(User.user_list)
else:
print('Did not confirm\n')
repeat = True

def create_account():
global user_name
global password
global repeat
global okay
if okay == 'OK':
user = User(user_name, password)
User.save_user(user)
print('Account created, proceed to Login\n')
# print(User.user_list)
else:
print('Did not confirm\n')
repeat = True

user_name = input('Enter your username\n ')
pass_choice = input(' a. Generate password\n'
' b. Create Password\n ')
def create_account():
global user_name
global password
global repeat
global okay

if pass_choice == 'a':
password = 1235
repeat = False
print(f'Your password is {password}')
okay = input('Type OK to Confirm\n ')
confirm_account_creation()

if pass_choice == 'b':
password = input('Enter your password\n ')
confirm_password = input('Confirm your password\n ')
user_name = input('Enter your username\n ')
pass_choice = input(' a. Generate password\n'
' b. Create Password\n ')

if password != confirm_password:
print('Passwords did not match, Try again\n ')
repeat = True
else:
okay = input('Type OK to Confirm\n ')
if pass_choice == 'a':
password = random_password()
repeat = False
print(f'Your password is {password}')
okay = input('Type OK to Confirm\n ')
confirm_account_creation()

else:
print('Option is not available\n')
repeat = True

if pass_choice == 'b':
password = input('Enter your password\n ')
confirm_password = input('Confirm your password\n ')

if password != confirm_password:
print('Passwords did not match, Try again\n ')
repeat = True
else:
okay = input('Type OK to Confirm\n ')
repeat = False
confirm_account_creation()

else:
print('Option is not available\n')
repeat = True

create_account()
while repeat == True:
create_account()

if choice == '2':
"""
Login section of the code
"""
def confirm_user_exists():
username = input('Enter your username')
password = input('Enter your password')
while repeat == True:
create_account()

if choice == '2':
"""
Login section of the code
"""
def confirm_user_exists():
username = input('Enter your username')
password = input('Enter your password')

# while password != passcode or username != name:
# pass

print('welcome')
if choice == '3':
exit()

# while password != passcode or username != name:
# pass

print('welcome')
if choice == '3':
exit()
else:
print('Choice is not available\n')
if __name__ == "__main__":
main()

# social = input('Enter the Socials Name,eg Instagram \n')
# input(f' Enter your {social} username \n ')
Expand Down
12 changes: 12 additions & 0 deletions credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import random
import string

# stringexample = 'abcdef'
# print(random.choice(string) + str(random.randint(1000,9999)) + random.choice(string)*2)

def random_string(length=8):
char_set = string.ascii_letters
return str(random.randint(1000,9999)) + ''.join(random.choice(char_set)for _ in range(length)/2)

password = random_string()
print(password)
5 changes: 3 additions & 2 deletions tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
while password != passcode or username != name:
# pass
else:
# print('Option is not available\n')
# repeat = True

0 comments on commit 9f54ab1

Please sign in to comment.