Created
September 4, 2018 21:17
-
-
Save nicain/08613fb821e0dd0ecbe0536c4ee2025d to your computer and use it in GitHub Desktop.
Get one:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def one(x, exception=Exception): | |
if len(x) != 1: | |
raise exception | |
if isinstance(x,set): | |
return list(x)[0] | |
else: | |
return x[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment