At the moment I have a block of code that allows me to find an exact line in a notepad file and the add it to GTINlist
. However I also want to add the line below that, and the line below that as well. I do not however want to import the rest of the file as a list.
This is my code at the moment:
GTINlist=[]
GTIN=input("Please enter your GTIN code. ")
GTINcodes = [line for line in open('GTINcodes.txt') if GTIN in line]
stringGTINcode = str(GTINcodes)
GTINlist.append(stringGTINcode)*