DJ49 DJ49 - 10 months ago 45
Python Question

Read this file and create a dictionary with keys of the type tuple and values of the type float

abcdefghijklmnopqrstuvwxyz try this as list and string and then dictionary and also tuple

Answer Source
with open(filename) as f:
    d = {tuple(x.split(':')[0].strip().split(',')): float(x.split(':')[1].strip()) for x in f}

This is a (fairly complex) dictionary comprehension.