2021年1月1日星期五

Q2() Function keeps looping

I'm making a simple menu for students to see and admins to login.

def main():      while(True):          print("1. Display Class")          print("2. Admin Login")                a = input("Please enter a choice or q to quit: ")          if a=="1":              Q1()          elif a=="2":              Q2()          elif a=="q":              break    def Q1():      print('Class A in Room 1, Class B in Room 2')    def Q2():      passwd = {'admin1': Q2}        user_input = input("Enter administrator password: ")      if user_input in passwd:          func = passwd[user_input]          func()          print ('Success')        else:          print("Incorrect password")      main()  print("Goodbye")  

The Q2() function does not work as I intended. It keeps looping "Enter administrator password: " when password is entered correctly.

https://stackoverflow.com/questions/65535561/q2-function-keeps-looping January 02, 2021 at 10:32AM

没有评论:

发表评论