0
cardA = copy(self.gamedata.memberData[str(ctx.author.id)]["cardA"])
cardA["status"] = None
cardA["health"] = cardA["stats"]["Hp"]
cardA["specialp"] = cardA["stats"]["sp"]
cardA["defeated"] = False
cardA["guarding"] = False
cardB = copy(self.gamedata.memberData[str(ctx.author.id)]["cardB"])
cardB["status"] = None
cardB["health"] = cardB["stats"]["Hp"]
cardB["specialp"] = cardB["stats"]["sp"]
cardB["defeated"] = False
cardB["guarding"] = False
cardC = copy(self.gamedata.memberData[str(ctx.author.id)]["cardC"])
cardC["status"] = None
cardC["health"] = cardC["stats"]["Hp"]
cardC["specialp"] = cardC["stats"]["sp"]
cardC["defeated"] = False
cardC["guarding"] = False
cardD = copy(self.gamedata.memberData[str(ctx.author.id)]["cardD"])
cardD["status"] = None
cardD["health"] = cardD["stats"]["Hp"]
cardD["specialp"] = cardD["stats"]["sp"]
cardD["defeated"] = False
cardD["guarding"] = False
cards = {
    "cardA": cardA,
    "cardB": cardB,
    "cardC": cardC,
    "cardD": cardD
}

When I alter any of these values it alters the actual value in member data is also changed. How do I stop that? I just want to make a copy and alter the copy without changing the original. At first, I just tried assigning it to a variable and altering that variable but that still changes the actual value. Then I tried importing copy and making a copy but that also didnt change anything. Any ideas how to fix?

Sylvester Kruin
  • 3,294
  • 5
  • 16
  • 39
  • 1
    Does this answer your question? [How to copy a dictionary and only edit the copy](https://stackoverflow.com/questions/2465921/how-to-copy-a-dictionary-and-only-edit-the-copy) – Kraigolas Feb 28 '21 at 02:05
  • 1
    Make sure you look at copy vs deepcopy https://docs.python.org/3/library/copy.html – CodeLikeBeaker Feb 28 '21 at 02:09

0 Answers0