Question: How to set an object in Python equal to another Object without affecting both values when I change one? Right now I have class hero():

How to set an object in Python equal to another Object without affecting both values when I change one?

Right now I have

class hero(): def __init__(self): self.gold = 5 self.strength = 0 self.hp = 10 self.armor = 0 self.maxHp = 10 self.inventory = []

hero = hero()

twinhero = hero

At some point in the program I want to make a twin hero with the same stats as the hero but I don't want a change in one to affect the other, how can I do this?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!