I have put in all of the code which I think is relevant to the question and my problem is with the last 4 lines in the if statement. I have tried defining 'term' as a different variable in case the problem was with the transfer between 2 functions but this still didn't work. I have also looked around on the internet but all of the answers appear to only be relevant to putting set values into the statement and not variables.
def FindItem(n = ''):
#Finds products by GTIN
shopping = 'yes'
while shopping == 'yes':
find("GTIN8", getNum("Enter the GTIN-8 of the product that you want: "))
shopping = input('do you want to add any more Items to your shop? ')
print('This is your recipt:')
recipt = open('temp.txt')
for eachline in recipt:
print(eachline, end = '')
recipt.close()
return os.remove('temp.txt')
def find(search, term):
# Helper function for the find function.
with connect("GTINb.db") as db:
cursor = db.cursor()
sql = "select * from GTINb where {} = ?".format(search)
cursor.execute(sql,(term,))
db.commit()
results = cursor.fetchall()
if results:
results = str(results)
temp = open('temp.txt', 'a')
temp.write(results)
temp.write('\n')
temp.close
with connect("GTINb.db") as db:
sql = "UPDATE GTINb SET stockcur=stockcur-1 WHERE GTIN8=term"
cursor.execute(sql)
return
else:
temp = open('temp.txt', 'a')
temp.write('Product not found')
temp.write('\n')
temp.close
return