subject_dic = {}
inputFile = open(filename)
for line in inputFile:
split_line = string.split(line, ',')
subject_dic[split_line[0]] = tuple(split_line[1:3])
print subject_dic
I'm getting
{'6.08': ('1', '10\n'), '6.09': ('3', '7\n'), '6.19': ('8', '19'), '6.10': ('8', '18\n'), '6.00': ('10', '1\n'), '6.01': ('5', '4\n'), '6.02': ('5', '6\n'), '6.03': ('2', '9\n'), '6.04': ('1', '2\n'), '6.05': ('1', '18\n'), '6.06': ('5', '19\n'), '6.07': ('2', '10\n'), '6.13': ('9', '16\n'), '6.18': ('10', '4\n'), '6.15': ('10', '6\n'), '6.16': ('6', '9\n'), '6.12': ('6', '3\n'), '6.17': ('9', '3\n'), '6.14': ('10', '8\n'), '6.11': ('6', '8\n')}
but I don't know how to remove '\n'
from the ends of my tuples. This is really simple but I can't find out how to do this. It's because I'm reading vertically from a file (hence the newline) but I don't want that '\n'
in my dictionary.
Thanks!