Also a tip if you want to save dictionary from @ichabod801 code.
You can use JSON.
You can use JSON.
import random import json testString = "abcd" data = {} for char in testString: data[char] = random.randint(2048, 4096) with open("test_file.json", "w") as j_out: json.dump(data, j_out)Now can read that JSON file from a other file.
import json with open("test_file.json") as j: data = json.load(j)Test:
>>> data {'a': 3183, 'b': 2707, 'c': 2581, 'd': 2144} >>> data.get('c', 'Not in record') 2581 >>> data.get('d', 'Not in record') 2144 >>> data.get('e', 'Not in record') 'Not in record'