title: How do I compare multiple objects to see if an attribute is equal between them?
body: <p>I'm an amateur at Python, and I'm trying to make a program for determining the initiative for a game I'm making, and part of that is making sure that two characters don't have the same "tick speed." Each character is an object with the following class code:</p>
  
  <pre><code>class Character(object):
          def __init__ (self, name, speed, agility, otick, tick):
                  self._name = name
                  self._speed = int(speed)
                  self._agility = int(agility)
                  self._otick = int(otick)
                  self._tick = int(tick)
  </code></pre>
  
  <p>and the following code for determining "tick speed":</p>
  
  <pre><code>if createCharacter._speed == 0: createCharacter.set_otick(-1)
          elif createCharacter._speed == 1: createCharacter.set_otick(30)
          elif createCharacter._speed == 2: createCharacter.set_otick(27)
          elif createCharacter._speed == 3: createCharacter.set_otick(24)
          elif createCharacter._speed == 4: createCharacter.set_otick(21)
          elif 5 &lt;= createCharacter._speed &lt;= 6: createCharacter.set_otick(18)
          elif 7 &lt;= createCharacter._speed &lt;= 9: createCharacter.set_otick(15)
          elif 10 &lt;= createCharacter._speed &lt;= 11: createCharacter.set_otick(14)
          elif 12 &lt;= createCharacter._speed &lt;= 13: createCharacter.set_otick(13)
          elif 14 &lt;= createCharacter._speed &lt;= 15: createCharacter.set_otick(12)
          elif 16 &lt;= createCharacter._speed &lt;= 17: createCharacter.set_otick(11)
          elif 18 &lt;= createCharacter._speed &lt;= 22: createCharacter.set_otick(10)
          elif 23 &lt;= createCharacter._speed &lt;= 28: createCharacter.set_otick(9)
          elif 29 &lt;= createCharacter._speed &lt;= 34: createCharacter.set_otick(8)
          elif 35 &lt;= createCharacter._speed &lt;= 43: createCharacter.set_otick(7)
          elif 44 &lt;= createCharacter._speed &lt;= 61: createCharacter.set_otick(6)
          elif 62 &lt;= createCharacter._speed &lt;= 97: createCharacter.set_otick(5)
          elif 98 &lt;= createCharacter._speed &lt;= 169: createCharacter.set_otick(4)
          elif 170 &lt;= createCharacter._speed &lt;= 225: createCharacter.set_otick(3)
          createCharacter.set_tick(createCharacter._otick)
  </code></pre>
  
  <p>I was wondering how to code things so that if there are three or more characters in a battle, one command can check if at least two of them have the same "tick" value, so that when I do the countdown program, I won't have two characters reach 0 at the same time.</p>
  
  <p>My intention is to have the comparison check happen at character creation and when a character's turn is over and their "tick" is returned to its original value (which is stored in the "otick"). If at least two values are equal, then the program is to compare the two character's "agility" attribute and whichever is lower gets 1 added to the "tick" and another comparison is made to make sure another tie hasn't been created. If both agilities are equal, then I want it to (essentially) roll a die (based on the agility in question) and the loser gets the +1.</p>
  
  <p>Thank you for your consideration.</p>
  
  <p>EDIT:
  While the current answer did help a little, I feel I should clarify something in my code. I have what is above get referred to by this bit of coding:</p>
  
  <pre><code>characterList = []
  c=int(input("How many characters in this battle? "))
  for x in range(c):
          Character = createCharacter()
          characterList.append(Character)
  </code></pre>
  
  <p>and so all the Character objects are in a list together. So the question becomes how to compare objects in the list.</p>