Code:
sample_dict = {"train": [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],
"feedback": ['a', 'b', 'c', 'd', 'e']}
data = sample_dict["train"]
data.append(sample_dict["feedback"][0])
print("data = ", data)
print("sample_dict = ", sample_dict)
Output:
data = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], 'a']
sample_dict = {'train': [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], **'a'**], 'feedback': ['a', 'b', 'c', 'd', 'e']}
i have save the sample_dict["train"] into data by data = sample_dict["train"] and then i appended the data with "a" when i print the data its working fine..but when i print the original dictionary its also gets change and you can see the bold "a" in sample_dict under key "train"..
Required Output:
data = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], 'a']
sample_dict = {'train': [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], 'feedback': ['a', 'b', 'c', 'd', 'e']}
need help.