I'm sorry if I phrased this wrong, but I will try my best to explain what I want to do.
Is it possible to do this in Python -
class Character():
strength, skill = 0, 0
def foo(self, strength, skill):
if c1.strength > c2.strength:
#something here
c1 = Character()
c2 = Character()
c1.strength = 15
c2.strength = 13
I don't really know how to explain this, but what I am trying to do is use the variables from the two instances that I made, inside the method?
Would that code work, or is there anything else? Thanks in advance.
You could just pass the other instance:
def foo(self, other_character):
if self.strength > other_character.strength:
#something here
c1 = Character()
c2 = Character()
c1.strength = 15
c2.strength = 13
c1.foo(c2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With