Given a list of python strings, how can I automatically convert them to their correct type?
Meaning, if I have:
["hello", "3", "3.64", "-1"]
I’d like this to be converted to the list
["hello", 3, 3.64, -1]
where the first element is a string, the second an int, the third a float, and the fourth an int.
How can I do this?
1 Answer