A school system



Basically, for a school project, we are supposed to design a school system. it is supposed to ask for a password and ask for information (the username of a student and the name of that student). the code works but there is an error that i need to fix. i want it to ask for the username and then the name of the person. however, the code does it vice versa

studentInfo = open("Student Information Database.txt","w")

studentInfoNeeded = ["username","name"]#the information needed

tries = 3#the amount of tries the Mr.Leeman can take to login
usernameSucceeded = False #i will make this true and break the while loop below as otherwise the loop won't end when he logs in
passwordSucceeded = False #the password for the account

def loginCheck(usernameOrPassword,login):#a program to check if his login is correct
    if login == usernameOrPassword:
        return True
        return False

success = False#to make sure that the imposter can't access the student information

while tries >= 0 and usernameSucceeded == False and passwordSucceeded == False:#a login to check if his username and password is correct
    asking = input("what is your username?")
    username = loginCheck(asking,"Leeman123")#to check his username
    if username == True:
        passwordAsking = input("what is your password?")#to get the password
        passwordCheck = loginCheck(passwordAsking,"password123*")#to check the password
        usernameSucceeded = True#to help break the loop

        if passwordCheck == True:
            passwordSucceeded = True#to break the loop
            success = True#to let Mr.Leeman access the student information

            tries -= 1#to decrease the tries left
            print("please retry")

        print("please retry")
        tries -= 1

end = False#to break another while loop while Mr.Leeman doesn't want to exit

studentReport = [[]]#an empty 2D array
studentReportIndex = 0#to get to the other array in the 2D array after each student

while end == False and success == True:#the and is there so it would not carry on if he wanted to exit
    choice = int(input("""What would you like to do:
1-add a student
2-delete a student
3-change a student's details
4-get a report
5-end"""))#the menu
    if choice == 5:
        end = True#to write everything to the file aafter he has finished

    elif choice == 1:
        for i in range(0,len(studentInfoNeeded)):
            question = "What is the student's "+studentInfoNeeded[i-1]+" ?"#to ask this question later on
            answer = input(question)



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.