Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
auh8Chatbot/lab1.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
117 lines (39 sloc)
1.83 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import sys | |
import random | |
from collections import defaultdict | |
#make a function | |
Name = list() | |
userID = list() | |
UserPassword = list() | |
with open( 'marks_test.csv', newline='\n') as csvfile: | |
reader = csv.reader( csvfile ) | |
for row in reader : | |
Name.append(row[0]) | |
userID.append( row[1] ) | |
UserPassword.append( row[2] ) | |
def check_User_Info(user_input1, user_input2): | |
for member_index in range( len(userID)): | |
member_userID = userID[ member_index ] | |
member_userPassword = UserPassword[ member_index ] | |
member_name = Name[ member_index ] | |
for elem in userID: | |
if user_input1 == elem: | |
print("Correct UserID.") | |
member_index = userID.index(user_input1) | |
if user_input2 == UserPassword[ member_index ]: | |
print("welcome!") | |
return True | |
else: | |
print("your password or UserID is not valid, please try again") | |
return False | |
while True: | |
user_input1 = input("Please enter userID:") | |
user_input2 = input("Please enter your password") | |
y = check_User_Info(user_input1, user_input2) | |
if y == True: | |
break | |
else: | |
print("your password or UserID is not valid, please try again") | |
continue | |
check_User_Info(user_input1, user_input2) | |