A query produces multiple lines answer, not always all lines have any output/result, and would produce an empty row []
I want to
- when any line has a result to be shown and ignore all other empty rows [Case 1]
- if all rows are empty print out one single message. [Case 2]
I have tried a number of options with loop statement if & else
and all()
or any()
however my best shot is to fulfil the first requirement only- I am unable to get the second requirement for all empty.
a snippet of the code that only delivers the 1st requirement
f = query(data)
for x in f:
if x:
print(x)
else:
if all(x):
print("no f found")
also, I have tried both any()
and all()
and their not
variation with no luck
Case 1 the output of f query, when there are some results, [in this case only 2 results out of 4]
['p=SDVjXSERgCziEsyhT4dIySuh9ha5Udt5b9F5TATeJ']
[]
['p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC31']
[]
desire output
p=SDVjXSERgCziEsyhT4dIySuh9ha5Udt5b9F5TATeJ
p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC31
Case 2, the output of f query, when there is no result at all
[]
[]
[]
[]
desire output
no f found
**What I don't want is to get a ** no f found
for each row that is empty
p=SDVjXSERgCziEsyhT4dIySuh9ha5Udt5b9F5TATeJ
no f found
p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC31
no f found
or
no f found
no f found
no f found
no f found
would really appreciate if anyone can give me a hand