Sep-22-2019, 02:03 PM
I want to create a dict from txt file, with words & summed ascii value but once again I have been defeated.
I guess I have never really understood dicts, in Python they arent intuitive at all and I just keep forgetting it all.
My worthless struggles:
I guess I have never really understood dicts, in Python they arent intuitive at all and I just keep forgetting it all.
My worthless struggles:
# coding=utf-8 coded, words = open("scrambled-words.txt", "r", encoding="UTF-8"), open("dictionary.txt", encoding="UTF-8") coded, words = [x.strip('\n') for x in coded], [x.strip('\n') for x in words] def bit_ops(coded, words): bit_list = {} for x in coded: bit_list = dict(zip(coded, [ord(y) for y in x])) print(bit_list)Gets me pathethic results like :
Output:{'dnaoyt': 116, 'cinuertdso': 115, 'bda': 115, 'haey': 101, 'tolpap': 101, 'slaayr': 110, 'eortem': 118}
I have tried few other things with '__setitem__' and 'update' and I failed too, so Im out of ideas.