This blog is mainly about the summary of list in Python. You can get the following knowledge points by implementing the following program
1. List: add: names.append(), names.insert(index, "character") names.extend(name) name is also a list
Delete: names.remove("string") del names[index] names.pop()
This: names[index] = "character"
In, not in
2. Usage of *: "*" * 10
3. len (names) len function gets the number of elements
4. If elif else use
5.range(0,15) 0 to 14
6.while loop break out
7. Print ("", end = ') does not wrap in a loop
8.input ("dsadsa dsa") input as string requires cast
9. After the pass takes up the position, when writing code, you can write the general framework first. Then complete the specific content.
#User prompt print(" Business card management system ") print("*"*10) print("1.Query business card information") print("2.Modify business card information") print("3.Delete business card information") print("4.Add business card information") print("5.Print business card list") print("6.Sign out") print("*"*10) #Business card storage control names = ["Mao Mao","tearful","every day"] #User input while True: num = int(input('User input')) #Execute output if num == 1: srchname = input('Query name:') if srchname in names: print("This business card exists") else: print("This business card does not exist") elif num == 2: number = int(input('Name and serial number before modification')) if number >= len(names) or number <0: print("No current serial number") else: chgnamea = input('Modified name') names[number] = chgnamea print("Modification completed") elif num == 3: number = int(input('Deleted name sequence number')) if number >= len(names) or number <0: print('No such serial number.') else: del names[number] print('Delete successful') elif num == 4: addname = input('Added name') names.append(addname) print('Increase success') elif num == 5: for i in range(0,len(names)): print("%d%s"%(i,names[i]),end = '') print('') elif num == 6: break print('Program has exited') else: print("Illegal input,Please re-enter")