I began writin down my login data in a text file, now it got very big so i wrote a small program where I can type in a website and get the login data. It works when I write the website exactly like in the text file but I want to implement a system that gives me the closest match when I mess the name up.
def search_and_print(website): passwort_text = open("D:/Programme/Python/Projects/test", "r+") points_text = open("D:/Programme/Python/Projects/Point record", "r+") letter_list =  line_list =  index = 0 for line in passwort_text.readlines(): counter = 0 if website.upper() in line.upper(): check = True try: if line != "\n" and check: print("\n" + line, end="") elif line == "\n": check = False except UnboundLocalError: pass # the code above looks for in all lines for the exact word I gave it and gives me # the next lines until it hits an empty line else: for letter in website: letter_list.append(letter) for letter_line in line: line_list.append(letter_line) if letter_list[index] == line_list[index]: counter += 1 index += 1 print("test") else: print(line_list[index]) #print(letter_list[index]) index += 1 # my idea here was to write the current line in a list as separate letters, so I can compare this list # with a list where I did the same for the input the programm gets points_text.close() passwort_text.close()
My question here would be if this is a good aproach or not and if not how I could do it better.
Thanks in advance.
this is the content of the test file I use: