3

I'm writing a Python script to manipulate Excel files, I'm using the openpyxl module, does anybody know how can I check if a user input is in a column, I've done this:
newItem = input("What is the new item?")
for itemChecker in inventory["A"]:
>>>>if itemChecker == newItem:
>>>>>>>>item_on = True
>>>>if itemChecker != itemNuevo:
>>>>>>>>item_on = False
if the user input (newItem) is in the "A" column of the variable assigned to an Excel file called "inventory", the variable "item_on" is set equal to True, if the user input isn't in the "A" column, "item_on" is set equal to False
what am I doing wrong, I'm not getting any errors but it always says that the user input isn't at the "A" column (sets "item_on" equal to False) even when I know it is

Comments
  • 0
    ill have too test it but you could try using the in operator eg
    if item in sheet["A"]:
Add Comment