Created
January 20, 2018 20:13
-
-
Save ysnerdem/4e864c51e0931203c25d1c9a8d19738c to your computer and use it in GitHub Desktop.
Extract values from list with raise
This file contains 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
lst = ["a",2,"bc",76,86,"sasa",1.86,0.5,(36,45),("a","b")] | |
def value_type_extcract(type_exam,value): | |
if type(value) != type(type_exam): | |
raise ValueError("incompatible value") | |
else: | |
return value | |
for i in lst: | |
try: | |
print(value_type_extcract((1,2), i)) | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment