I have the following dictionary:
things = { 0: ["32 64 43 12 67", "14 35 61 46 89"] 1: ["23 54 11 59 90", "56 6 91 11 19"] }
I want to iterate through the numbers and in order to do that I need to transform them into integers. I tried splitting the strings using
for z in range(len(things)):
for c in things[z]:
c = c.split(" ")
but it doesn’t change anything
>Solution :
You can transform your input to the required output using nested comprehensions.
output = {k: [[int(x) for x in s.split()] for s in v] for k, v in things.items()}