Skip to content

Instantly share code, notes, and snippets.

@ysnerdem
Created January 20, 2018 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysnerdem/4e864c51e0931203c25d1c9a8d19738c to your computer and use it in GitHub Desktop.
Save ysnerdem/4e864c51e0931203c25d1c9a8d19738c to your computer and use it in GitHub Desktop.
Extract values ​​from list with raise
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