Commit d3201417 authored by Loic Huder's avatar Loic Huder
Browse files

Added snippet for EAFP at the end of pres02

parent b74668c3
Pipeline #32980 passed with stage
in 52 seconds
......@@ -1339,7 +1339,27 @@
In this particular case, using `try` and `except` is far easier !
%% Cell type:code id: tags:
``` python
split_list = []
for value in str_variables.split("\n"):
if value.isdecimal():
value = int(value)
print(value, "is not a int")
int_part, sep, dec_part = value.partition('.')
if int_part.isdecimal() and dec_part.isdecimal():
value = float(value)
print(value, 'is not a float')
%% Cell type:code id: tags:
``` python
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment