I am new to Python. I want to call a function that detect null value in a excel table and passing "Fail" to a variable stat.
def checkBlank(tb):
book=xlrd.open_workbook(reportFile)
sheet = book.sheet_by_name(tb)
s= "Pass"
for i in range(sheet.nrows):
row = sheet.row_values(i)
for cell in row:
if cell =='':
s="Fail"
return s
print checkBlank('Sheet1')
Above code will return "Fail" but below code will give: NameError: name 'stat' is not defined
def checkBlank(tb,stat):
book=xlrd.open_workbook(reportFile)
sheet = book.sheet_by_name(tb)
s= "Pass"
for i in range(sheet.nrows):
row = sheet.row_values(i)
for cell in row:
if cell =='':
s="Fail"
print checkBlank('Sheet1', stat)
print stat
How can I assign "Fail" to stat if the function find the empty cell?