This is my current code:
StockSearch = input("Search For Product (Name Or Code):\n")
with io.open('/home/jake/Projects/Stock','r', encoding='utf8') as f:
for line in f:
Read = f.readline()
while Read!='':
if StockSearch == Read:
print (Read)
I'm trying to get python to keep reading every line of the file until there are none left and match the user's input with one of the lines, if not it'll print an error code.
Thank you in advance.
StockSearch = input("Search For Product (Name Or Code):\n")
found = False
with io.open('/home/jake/Projects/Stock','r', encoding='utf8') as f:
for line in f:
line = line.rstrip('\n')
if StockSearch == line:
print(line)
found = True
break
if not found:
print("Nothing found")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With