I have a problem with python code and i don't know what to do, because im fairly new in it.
date_now1 = datetime.datetime.now()
archive_date1 = date_now1.strftime("%d.%m.%Y")
f1 = open(archive_date1, "r+")
print("What product do you wish to delete ?")
delate_product = str(input())
for line in f1.readlines():
if delate_product in line:
list = line
ready_product = list.split()
quantity_of_product = int(ready_product[1])
if quantity_of_product == 1:
del line
print("Product deleted")
else:
print("You have {} amounts of this product. How many do you want to delete ?".format(quantity_of_product))
x = int(input())
quantity_of_product = quantity_of_product - x
temporary = "{}".format(quantity_of_product)
print(type(temporary))
f1.write(temporary) in ready_product[1]
I get the message
f1.write(temporary) in ready_product[1]
TypeError: 'in <string>' requires string as left operand, not int
When i do print(type())
in temporary it says string. I also tried str(quantity_of_product)
, but it doesn't work as well. Maybe somebody could give me the idea of what to do, or what to read to get the answer.