ACTION_CHOICES = Approve Reject Request more information Delegate Send back Recall Escalation - Task Escalation - Email Reminder another_list = Approve Reje
Here's one way to do it in Python:
ACTION_CHOICES = [
"Approve",
"Reject",
"Request more information",
"Delegate",
"Send back",
"Recall",
"Escalation - Task",
"Escalation - Email",
"Reminder",
]
another_list = ["Approve", "Reject"]
# Check if all values in another_list exist in ACTION_CHOICES
if all(action in ACTION_CHOICES for action in another_list):
print("True")
else:
print("False")
The all() function checks if all values in a given iterable (in this case, another_list) evaluate to True. The expression action in ACTION_CHOICES returns True if action is found in ACTION_CHOICES, and False otherwise. By passing a generator expression to all(), we can check if all values in another_list are found in ACTION_CHOICES. If so, all() returns True, and we print "True". If not, all() returns False, and we print "False".
原文地址: https://www.cveoy.top/t/topic/bCux 著作权归作者所有。请勿转载和采集!