-1

I currently have this dictionary:

import string
import random
List = string.ascii_letters + string.digits + string.punctuation + " "
dictionary1 = dict.fromkeys(encryptionList, [None, None, None])
List = list(List)
random.shuffle(List)
joined = ''.join(List)
print(joined)

I want to change each None inside of the dictionary one by one, but the list is overwritten every time, so the very last operation is the only one that stays, how could I do this to where each of the inserted values stay and I have a full list that is not overwritten? Here's the code I have tried running:

for key1 in dictionary1:
    if len(joined) > 0:
        toDel = joined[0]
    first = dictionary1[key1]
    first[0] = toDel
    joined = joined.replace(toDel, '')
    joined = list(joined)
    random.shuffle(joined)
    joined = ''.join(joined)

for key2 in dictionary1:
    if len(joined) > 0:
        toDel = joined[0]
    second = dictionary1[key2]
    second[1] = toDel
    joined = joined.replace(toDel, '')
    joined = list(joined)
    random.shuffle(joined)
    joined = ''.join(joined)

for key3 in dictionary1:
    if len(joined) > 0:
        toDel = joined[0]
    third = dictionary1[key3]
    third[2] = toDel
    joined = joined.replace(toDel, '')
    joined = list(joined)
    random.shuffle(joined)
    joined = ''.join(joined)
Dean
  • 1
  • 3

0 Answers0