bit stuck on something which is probably easy to solve, but all of the examples I found are talking about uniform key:value pairs.
What I want to achieve is the following :
I have a dictionary containing mixed values (strings and floats), and all the floats should be converted to int, otherwise the string is kept.
example :
d = {"key1":"something","key2":200.0, "key3":"another string", "key4":2017.0}
should become :
{"key1":"something","key2":200, "key3":"another string", "key4":2017}
I tried something like this in some variations but no luck
d = {k: int(v) if float(v) else v for k, v in d.items()}
What would be the best approach to achieve this?