DJ49 DJ49 - 2 months ago 12
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
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. https://www.python.org/dev/peps/pep-0274/