Here I wrote the following code to search for headers from an excel sheet, it can search for the headers, but for each successful iteration, it prints success separately and also same for the error.
for i in sheet_data:
if (i[0] == "BN") and (i[1] == "YOU"):
found_list.append(i)
print("Success")
else:
print("error")
>
error
error
error
Success
error
Success
error
error
If the iteration found the string at once or twice then print success only once hence it will not print error. If there is no success iteration then only it has to print error (else) once. (I just need to print success or error)