Advertisement
DeaD_EyE

mutually exclusive

Jul 3rd, 2021
1,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def mutually_exclusive(values) -> bool:
  2.     """
  3.    Return True if only one value in values is True.
  4.    In all other cases, False is returned.
  5.    """
  6.     result = False
  7.    
  8.     for value in values:
  9.         if not result and value:
  10.             result = True
  11.         elif result and value:
  12.             return False
  13.            
  14.     return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement