swindell4 / MO8_Final_Project

0 stars 0 forks source link

Module 4: Deadline 2 #11

Open swindell4 opened 2 weeks ago

swindell4 commented 2 weeks ago

Attach the search algorithm to the given checklist box, search field, and button.

nnatsd12349 commented 1 week ago

@swindell4

Liked the search, made some sugestions.

  1. the del results line will raise an error if results does not exist. simply initializing results to an empty list fixes this.
  2. re.search checks matches in a whole string, re.match checks only the beginning of a string.
  3. added error handling where searchField or database.db isn't defined or available.

results = [] # This list will contain all the matching results to the data within the search field. search = search_field # This will capture the current data in the search field.

for data in database:  # This loop will iterate through the contents of the database.
    if re.search(search, data):  # Check if the current database element matches the search field data.
        results.append(data)  # Add the matching data to the results list.

return results