The second week - the 12th chapter -Python3.5- use dictionaries - dictionaries practice


print ( '' '| --- Welcome to the address book program --- | | --- 1, query the contact information --- | | --- 2, insert a new contact --- | | - -3, deleting an existing contact --- | | ---. 4, address book program exit --- | '' ') the addressBook} = {# define contacts the while. 1: TEMP iNPUT = (' enter instruction code : ') IF not temp.isdigit (): Print ( "instruction is entered by mistake, please follow the prompts to enter") the Continue Item = int (the TEMP) # is converted to digital IF == Item 4: Print ( "| --- thanks use address book program --- | ") BREAK name = the iNPUT (" Please enter the contact name: ") IF == Item 1: IF name in addressBook: Print (name, ':', addressBook [name]) the Continue the else : Print ( "the contact does not exist!")) if item==2: if name in addressBook: Print ( "The name you entered already exists in the address book - >>", name, ":", addressBook [name]) isEdit the INPUT = ( "whether to modify the contact information (Y / N) : ") IF isEdit == 'the Y': USERPHONE = iNPUT (" Please enter the contact phone: ") the addressBook [name] = USERPHONE Print (" contacts successfully modified ") Continue the else: Continue the else: USERPHONE = iNPUT (" Please enter the contact telephone: ") addressBook [name] = USERPHONE ! Print (" contact to the success of ") the Continue IF == Item 3: IF name in addressBook: del addressBook[name] print ( "deleted successfully!")) continue else: print ( "contact does not exist.")

Guess you like

Origin www.cnblogs.com/pcjbk/p/10958924.html