Mar-30-2021, 06:02 PM
Hello, I am doing an assignment and not sure what im doing wrong. My job is to search the columns and rows of an excel file using openpxyl. So far I have got this code done.
Each column has 100 words and there is 4 rows.
When I have entered a word that I know thats in the file I get nothing back.
I have tried replacing the part of the code:
if userGuess == cell:
print(cell)
with print (cell)
and I get the word that is in the file outputted back to me.
I'm new to programming so Im not sure what I'm doing wrong here.
Thanks.
import openpyxl def functionOne (): print("Please enter the word you would like to find in the excel sheet.") userGuess = input() sampleWorkbook = openpyxl.load_workbook("c:\\Assignment.xlsx") sheet = sampleWorkbook.active for col in sheet.iter_cols(min_row=1, max_col=4, max_row=100): for cell in col: if userGuess == cell: print(cell) functionOne ()So, I need to output the column and row ID if the word was found in the list.
Each column has 100 words and there is 4 rows.
When I have entered a word that I know thats in the file I get nothing back.
I have tried replacing the part of the code:
if userGuess == cell:
print(cell)
with print (cell)
and I get the word that is in the file outputted back to me.
I'm new to programming so Im not sure what I'm doing wrong here.
Thanks.