I have an issue that really drives me mad. Normally doing int(20.0)
would result in 20
. So far so good. But:
levels = [int(gex_dict
'20.0'
is a string, not a float
; you can tell by the single-quotes in the error message. You can get an int
out of it by first parsing it with float
, then truncating it with int
:
>>> int(float('20.0'))
20
(Though maybe you'd want to store floats instead of strings in your dictionary, since that is what you seem to be expecting.)