currently I have a list called itemList whereby the data are retrieved and passed into it from a text file. After all the formatting, the data in the list comes out as shown as below:
['1', 'Apple', '2.00', '0'], ['2', 'Orange', '1.50', '0'], ['3', 'Cabbage', '5.50', '100']
the arrangement is [item code, item name, price, quantity].
right now, what im trying to do is that i want to let users to search for a specific thing and it will search through everything in the list and prints out whatever that contains it but what I have now is that you need to be specific with what you search, meaning lets just say i want to search for Apple, I need to type in "Apple" specifically to search for it, but, what I want is for Apple to show up even if i only typed in "a".
I want to know if there's any built in functions or any way to do this? My current code is as shown:
with open("itemList.txt", "r") as itemFile:
for row in itemFile:
row = row.strip("\n")
itemList.append(row.split())
for everything in itemList:
if str(search) in everything:
print(everything[0]+" "+everything[1]+" "+everything[2]+" "+everything[3]+"\n")