Apr-21-2024, 06:55 AM
If you had provided some data that would have been nicer!
You can make an empty dictionary like this:
Loop through the keys and replace the empty string with anything you like:
You can make an empty dictionary like this:
mydict = {j:'' for j in range(25)}j is the key and the value is an empty string.
Loop through the keys and replace the empty string with anything you like:
for key in mydict.keys(): mydict[key] = 'value' + str(key + 1)Like I said, if you had provided some data, that would have been better!
import uuid from random import choice, randint from string import ascii_lowercase # make a random string for rd_info[0] def randomString(): random_string = ''.join([choice(ascii_lowercase) for i in range(4)]) return random_string # make a random integer for rd_info[3], rd_info[6], rd_info[13] def randomInt(): random_integer = randint(1989, 2022) return random_integer # make some data because you did not provide any data # make a list of lists data = [[randomString(), randomInt(), randomInt(), randomInt(), 0, 0] for i in range(25)] # make some fairly unique keys: keys = [str(uuid.uuid4()) for i in range(25)] # make a dictionary of empty strings mydict = {key:'' for key in keys} # now populate mydict with your data # you did not provide a sample of your data so I can't use your data i = 0 for key in mydict.keys(): # put a data list in mydict as value mydict[key] = data[i] i +=1