How To To Save One Document Based On An If Statement In Python?
I am trying to save a document based on a if statement. Here I am creating radiobuttons: info = ['Option 1', 'Option 2', 'Option 3'] vars = [] for idx,i in enumerate(info): v
Solution 1:
Question: The
'Failed.docx'
will only be createdif one or more
out of all theoptions
has ano
value selected.
This can be rephrased to:
if any option has NO
You have build a list
of Boolean
from the condition value == NO
,
like [False, True, False]
- Built-in - any
any(iterable)
Return True if any element of the iterable is true. If the iterable is empty, return False.
YES = 2; NO = 1; NA = 0print(vars)
ifany([v.get() == NO for v invars]):
print('Failed.docx')
else:
print('test.docx')
Output:
[2, 0, 2]
test.docx
[2, 1, 2]
Failed.docx
Solution 2:
Try the following:
for x in cells[2].text:
if"*"in x:
print("Failed.docx")
elif"*" not in x:
print("Test.docx")
this checks if any "*"
is inside your no
row, if it exists save as Failed.docx
if not save as Test.docx
Post a Comment for "How To To Save One Document Based On An If Statement In Python?"