Right now I get this:
[[28, 27], [29, 27], [29, 28], [29, 29], [28, 29], [27, 29], [27, 28], [27, 27]]
I want this output:
[(28, 27), (29, 27), (29, 28), (29, 29), (28, 29), (27, 29), (27, 28), (27, 27)]
My code:
def load_seed_from_file(_file_name: str) -> tuple:
""" Load population seed from file. Returns tuple: population (dict) and world_size (tuple). """
population = {}
file_name = Path(RESOURCES / str("seed_" + _file_name + ".json"))
print(file_name)
with open (file_name, "r") as json_file:
loaded_json = json.load(json_file)
for key, value in loaded_json.items():
if key == "world_size":
world_size = tuple(value)
print(world_size)
else:
for i in value:
if value[i] != None:
print(value[i]["neighbours"])
else:
population.update({i: value[i]})
print(population)
return (population, world_size)
I'd like to change my list with lists to a list with tuples
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…