Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv #import file reader
- import time #import time
- import random #import random
- import operator #import operators
- import sys #import system specific parameters
- def Registration(): #used later on in choice 1
- userfile = open("userfile.csv", "a") #use the userfile.csv
- username = input("Enter your username ") #username input
- password = input("Enter your password ") #password input
- WriteLine = username + " " + password + " " #writes lines within userfile.csv from username and password
- userfile.write(WriteLine) #write the line
- userfile.close() #close the userfile
- print ("\nAccount created") #print that the account is created
- Menu() #open the menu
- def Menu(): #the menu itself defined
- print (30 * '-') #UI
- print (" M A I N - M E N U") #UI
- print (30 * '-') #UI
- print ("1. Register") #UI
- print ("2. Play")#UI
- print (30 * '-') #UI
- choice = input('Enter your choice [1-2] : ') #defines choice between 1 and 2
- choice = int(choice) #string
- if choice == 1: #if the choice is 1 (register)
- print ("Register Selected") #print register is selected
- Registration() #run registration
- if choice == 2: #if the choice is 2 (play)
- print ("Play Selected") #print play select
- LogIn() #next code to run
- def LogIn():
- loginUsername = input("Enter your login username ") #username input
- loginPassword = input("Enter your login password ") #password input
- loggedIn = False
- with open('userfile.csv', 'rb') as csvfile:
- userfile = csv.reader(csvfile, delimiter=',')
- for row in userfile:
- if loginUsername in row:
- if loginPassword in row[2]:
- loggedIn = True
- else:
- print("Invalid Password")
- else:
- print("Invalid Username")
- print ("Logged In")
- ############################### call from here ################################
- Menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement