Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_file_contents(file_path):
- return [line.strip() for line in open(file_path)]
- hourslist = get_file_contents(hours_path)
- def add_file_contents(file_path, contents):
- with open(file_path, "a") as file:
- file.write(contents)
- def login_user(new_account=False):
- usernameslist = get_file_contents(users_path)
- passwordslist = get_file_contents(passwords_path)
- if new_account:
- response = 'y'
- else:
- print(print_in_yellow)
- response = input("-"*50 + "nDo you have an account (y/n)? ")
- print("-"*50)
- print(print_default)
- #If user has an account:
- if response == "y":
- goodlogin = False
- #Ask user for unsername and password
- username = input("-"*50 + "nPlease enter your username: ")
- password = input("Please enter your password: ")
- #For the id in the usernames list: if the index of the id and password match
- #and the username and password are correct, there is a good login
- for id in range(len(usernameslist)):
- if username == usernameslist[id] and password == passwordslist[id]:
- goodlogin = True
- #If their login works:
- if goodlogin:
- #Tell the user access has been granted
- print(print_in_green + "Access granted!" + print_default + "n" + "-"*50)
- #Part 4:Log user in to practice
- #Ask if user is loging into a practice
- print(print_in_pink)
- practice = input("nnnWould you like to log a practice (y/n)? ")
- print(print_default)
- #If thet want to log in to a practice:
- if practice == "y":
- practice_hours = input("How many hours are you practing for? (PLEASE ROUND TO THE NEAREST HOUR) ")
- add_file_contents(hours_path, practice_hours + "n")
Add Comment
Please, Sign In to add comment