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[i]) for i in sorted(gex_dict.keys())]
while gex_dict[i] returns a float, e.g. 20.0, results in:
"invalid literal for int() with base 10: '20.0'"
I am just one step away from munching the last piece of my keyboard.
'20.0'is a string, not afloat; you can tell by the single-quotes in the error message. You can get anintout of it by first parsing it withfloat, then truncating it withint:(Though maybe you’d want to store floats instead of strings in your dictionary, since that is what you seem to be expecting.)