I am trying to let the user search an external file for 2 things after they tell me one of the things.. There are 3 different products and prices in the txt file in the form of:
however, this only shows the price of the apple, not the other two.. what's wrong?
def search(): keepgoing = True foundproduct = False while keepgoing == True: searchterm = input("What are you looking for? (type 'end' to quit)") if searchterm == 'end': keepgoing == False file_object = open('herp.txt', 'r') product = file_object.readline() price = file_object.readline() product = product.rstrip("\n") price = price.rstrip("\n") if product == '': keepgoing = False else: if searchterm == product: print("Product: ", product, "| Price: ", price) foundproduct == True else: print("Sorry, can't find it!") file_object.close() search()