How can I convert string values from a dictionary, into int/float datatypes?

We have got to love list comprehensions.

[dict([a, int(x)] for a, x in b.items()) for b in list]

(Remark: for Python 2-only code, you may use “iteritems” instead of “items”)

Leave a Comment