use Python to complete a simple name management system
#1. Print Feature tip print ("=" *30) print ("-" *5+ "Name Relational system" + "-*5) print (" 1. Add a new name: ") Print (" 2. Delete a name: ") Print (" 3. Modify a Name: ") print ("4. Query a name:") Print ("5. Query all:") print ("6. Exit system") print ("=" *30) names=[] #定义一个空的列表用来存储添加的名字 while True: #2. Get the user's Choice num =int (Input ("Enter function serial number:") #3. According to the user's choice, perform the corresponding function if Num==1:new_name=input ("Please enter first Name:") names.append (new_name) p
Rint (names) elif num==2:del_name=input ("Please enter the name to be deleted:") if Del_name in Names:names.remove (del_name) Else:print ("Cannot delete, the name to be deleted does not exist ...")
") elif num==3:edit_name=input (" Please enter the name to be modified: ") if Edit_name in Names:edit_name1=input (" Please enter first Name: ") Names[names.index (edit_name)]=edit_name1 else:print ("cannot be modified, the name does not exist ...
Elif num==4:find_name=input ("Please enter the name to query:") if Find_name in Names:print ("Find the person you are looking for") Else: Print ("No this person ... ") Elif Num==5:print (names) elif Num==6:print (" Successfully exited system ... ") Break Else:print (" Your input is incorrect, pleaseRe-enter ...
")