Python: business card management system

Keywords: Python

String and list,

I tried to write a very simple business card management system,

Xinmeng tries,

Don't spray,

I stole the function of modifying business card,

Because I don't know how to modify the strings in the list by defining subscripts and then subscripts

My idea is to delete the business card that the user is going to modify, and then add the newly named business card;

If there is a big guy who has a direct way to modify it, please give me some advice...

The code is as follows:

 1 name = []
 2 while True:
 3     print("="*50)
 4     print("        Welcome to business card management system V1.0")
 5     print("1: Add a business card")
 6     print("2: Modify a business card")
 7     print("3: Delete a business card")
 8     print("4: Query a business card")
 9     print("5: Sign out")
10     print("="*50)
11     admin = int(input("Please enter function number:"))
12 
13     if admin == 1:
14         while True:
15             new_name = input("Please enter your name:")
16             if new_name == "Return":
17                 break
18             name.append(new_name)
19             print("=======>Added successfully!")
20             print("=======>The names that have been added are:%s"%(name))
21             print("=======>To return to the menu, please enter: back")
22     elif admin == 2:
23         while True:
24             al_name = input("Please enter the name you want to modify:")
25             if al_name == "Return":
26                 break
27             if al_name in name:
28                 als_name = input("Please enter a new name:")
29                 name.remove(al_name)
30                 name.append(als_name)
31                 print("=======>The current names are:%s" % (name))
32             else:
33                 print("The name you entered does not exist, please re-enter!")
34             print("=======>To return to the menu, please enter: back")
35     elif admin == 3:
36         while True:
37             del_name = input("Please enter the name you want to delete:")
38             if del_name == "Return":
39                 break
40             name.remove(del_name)
41             print("=======>Delete successfully!")
42             print("=======>The remaining names are:%s" % (name))
43             print("=======>To return to the menu, please enter: back")
44     elif admin == 4:
45         while True:
46             look_name = input("Please enter the name you want to query:")
47             if look_name == "Return":
48                 break
49             else:
50                 if look_name in name:
51                     print("The name you want to query exists!")
52                 else:
53                     print("No one!")
54             print("=======>To return to the menu, please enter: back")
55     elif admin == 5:
56         break
57     else:
58         print("Your input is wrong, please input from New!")

Posted by lisaNewbie on Fri, 01 May 2020 14:58:02 -0700