Python: business card management system (problems occurred after adding login function, asking for advice)

I defined a simple business card management system as a function..

2 layers.

A login interface;

A business card management system user interface;

The logic is: login succeeded =, jump into the card system user interface, and at the same time, jump out of the login interface, give welcome to use, and the program ends.

At this time, the problem is: you should log out of the business card system interface. As a result, the first layer should also jump out. The second layer is now

 1 def mingpian():
 2     name = []
 3     name_fl = 0
 4     while name_fl == 0:
 5         print("="*50)
 6         print("        Welcome to business card management system V1.0")
 7         print("1: Add a business card")
 8         print("2: Modify a business card")
 9         print("3: Delete a business card")
10         print("4: Query a business card")
11         print("5: Sign out")
12         print("="*50)
13         admin = int(input("Please enter function number:"))
14 
15         if admin == 1:
16             while True:
17                 new_name = input("Please enter your name:")
18                 if new_name == "Return":
19                     break
20                 name.append(new_name)
21                 print("=======>Added successfully!")
22                 print("=======>The names that have been added are:%s"%(name))
23                 print("=======>To return to the menu, please enter: back")
24         elif admin == 2:
25             while True:
26                 al_name = input("Please enter the name you want to modify:")
27                 if al_name == "Return":
28                     break
29                 if al_name in name:
30                     als_name = input("Please enter a new name:")
31                     name.remove(al_name)
32                     name.append(als_name)
33                     print("=======>The current names are:%s" % (name))
34                 else:
35                     print("The name you entered does not exist, please re-enter!")
36                 print("=======>To return to the menu, please enter: back")
37         elif admin == 3:
38             while True:
39                 del_name = input("Please enter the name you want to delete:")
40                 if del_name == "Return":
41                     break
42                 name.remove(del_name)
43                 print("=======>Delete successfully!")
44                 print("=======>The remaining names are:%s" % (name))
45                 print("=======>To return to the menu, please enter: back")
46         elif admin == 4:
47             while True:
48                 look_name = input("Please enter the name you want to query:")
49                 if look_name == "Return":
50                     break
51                 else:
52                     if look_name in name:
53                         print("The name you want to query exists!")
54                     else:
55                         print("No one!")
56                 print("=======>To return to the menu, please enter: back")
57         elif admin == 5:
58             name_fl =1
59         else:
60             print("Your input is wrong, please input from New!")
61 
62         #=====Sign in
63 ad = {}
64 name_fl = 0
65 while name_fl == 0:
66     print("="*50)
67     print("Welcome to business card management system V1.0")
68     print("1.Sign in")
69     print("2.register")
70     print("3.Sign out")
71     print("="*50)
72 
73     admin_1 = int(input("Please enter function number:"))
74 
75     if admin_1 == 1:
76         while True:
77             admin = input("Please enter the login account:")
78             passwd = input("Please enter the login password:")
79             for admins,passwds in ad.items():
80                 if admin == admins and passwd == passwds:
81                     print("Login succeeded!")
82                     mingpian()
83 
84                 else:
85                     print("Wrong account or password! Please login again!")
86     elif admin_1 == 2:
87         while True:
88             new_zh = input("Please enter your account number:")
89             if new_zh in ad.keys():
90                 print("Account already exists! Please input from New!")
91             else:
92                 new_passwd = input("Please enter your registration password:")
93                 ad[new_zh] = new_passwd
94                 print("Registration succeeded!")
95                 break
96     elif admin_1 ==3:
97         print("Thank you for using the business card management system V1.0,bye!")
98     else:
99          print("Input error, please input again!")

 

Can't jump out....

Keywords: Python

Added by lc21 on Sat, 02 May 2020 16:57:46 +0300