Example #1
0
    def search_by_attribute(self):
        print(
            'How would you like to search the contact list? Enter id, first_name, last_name, email or note'
        )
        search_attribute = input()

        print(f'Please enter new {search_attribute}')
        new_value = input()
        Contact.find_by(search_attribute, new_value)
Example #2
0
 def search_by_attribute(self):
     select_attribute = input(
         'Enter the attribue you would like search by, first name, last name, email or note: '
     )
     select_term_to_search = input(
         'Enter the term you would like to find: ')
     print(Contact.find_by(select_attribute, select_term_to_search))
Example #3
0
 def search_by_attribute(self):
     print(
         "Copy and paste the attribute would you like to search by:\nfirst_name\nlast_name\nemail\nnote"
     )
     search_field = input()
     print("What value would you like to search by?")
     search_value = input()
     x = Contact.find_by(search_field, search_value)
     print(x)
Example #4
0
 def search_by_attribute(self):
     if len(Contact.list_of_contacts) == 0:
         print("Error, no contacts to search")
     else:
         attribute = input(
             "Enter the attribute you would like to search: ").lower()
         value = input(
             "Enter the value you would like to search for: ").lower()
         if attribute == "id":
             value = int(value)
         print(Contact.find_by(attribute, value))
         print(" ")
Example #5
0
    def search_by_attribute(self):
        print("Select an attribute to search for")
        print("1 - First Name")
        print("2 - Last Name")
        print("3 - Email")
        print("4 - Note")
        attribute = int(
            input("Enter the number of attribute you want to search for: "))

        search_value = input("Enter the value of the attribute: ")

        if attribute == 1:
            search_attribute = 'first name'
            print(Contact.find_by(search_attribute, search_value))
        elif attribute == 2:
            search_attribute = 'first name'
            print(Contact.find_by(search_attribute, search_value))
        elif attribute == 3:
            search_attribute = 'first name'
            print(Contact.find_by(search_attribute, search_value))
        elif attribute == 4:
            search_attribute = 'first name'
            print(Contact.find_by(search_attribute, search_value))
Example #6
0
    def search_by_attribute(self):
        print('\n--SEARCH BY ATTRIBUTE--\n')
        print('\nSelect from the options below:')
        print('- first_name -')
        print('- last_name -')
        print('- email -')
        print('- note -')

        search_attribute = input()

        print('\n Enter search:\n')
        search_value = input().lower()

        print(Contact.find_by(search_attribute, search_value))
Example #7
0
 def search_by_attribute(self):
     searched = False
     attribute_dict = {1: 'first_name', 2:'last_name', 3: 'email', 4:'note'}
     while not searched:
         print('[1] First Name')
         print('[2] Last Name')
         print('[3] Email')
         print('[4] Note')
         searched_attribute = int(input('What do you want to search by?: '))
         if searched_attribute >= 1 and searched_attribute <= 4:
             search_attribute_variable = input('Please enter the search term: ')
             searched_contact = Contact.find_by(attribute_dict[searched_attribute], search_attribute_variable)
             if searched_contact:
                 print('')
                 print(searched_contact)
                 print('')
                 searched = True
             else:
                 print('Please try again')
         else:
             print('Please enter one of the following numbers')
Example #8
0
print("Find contact with id of {}:".format(requested_id))
print(Contact.find(requested_id))

print()
print("Successfully updating a contact:")
contact1.update("first_name", "Elizabeth")
print(contact1)

print()
print("Failed attempt to update a contact:")
print(contact1.update("first name", "Bettie"))
print(contact1)

print()
print("Successfully finding a contact by attribute name and value:")
print(Contact.find_by('first_name', 'Elizabeth'))

print()
print("Specifying an invalid attribute name in find_by() method:")
print(Contact.find_by('first name', 'Elizabeth'))

print()
print("Specifying an invalid attribute value in find_by() method:")
print(Contact.find_by('first_name', 'John'))

print()
print("Deleting all contacts:")
Contact.delete_all()
print(Contact.contacts)

print()
Example #9
0
 def search_by_attribute(self):
     print("Input the attribute that you want to search by")
     attribute = input()
     print("Input the value for that attribute")
     value = input()
     print(Contact.find_by(attribute, value))