I want to make a program that generates a certain number of random lists and then places these into another list. This is my code:
import random
RandomPassword=["0","0","0"]
PasswordList=[]
for Char in range(0,3):
RandomPassword[Char]=(random.randint(0,9))
PasswordList.append(RandomPassword)
print("Password list is", PasswordList)
I have used the .append() function to try and do this, but every time I run the program I end up with something like this:
Password list is [[4, 8, 1], [4, 8, 1], [4, 8, 1]]
>>>
I think it is something to do with the list being a mutable data type, but I'm not sure how to change this. I have trawled the internet and not found anything that I can understand that fixes my problem. I would like to see something like this:
Password list is [[3, 6, 7], [4, 8, 6], [2, 5, 4]]
>>>
Does anyone have a simple solution?