title: Python Attribute Error if statement
body: <p>I have been working on this code for about a day now. A few hours on just this one part it keeps saying I have an attribute error on line 26. Unfortunately that is all the information I have. I have tried countless different ways to fix it and have searched many websites/forums. I appreciate any help. Here is the code:</p>
  
  <pre><code>import itertools
  def answer(x, y, z):
      monthdays = {31,
                   28,
                   31, 
                   30, 
                   31, 
                   30, 
                   31, 
                   31, 
                   30, 
                   31, 
                   30, 
                   31}
      real_outcomes = set()
      MONTH = 0
      DAY = 1
      YEAR = 2
  
      #perms = [[x, y, z],[x, z, y],[y, z, x],[y, x, z],[z, x, y],[z, y, x]]
      possibilities = itertools.permutations([x, y, z])
      for perm in possibilities:
          month_test = perm[MONTH]
          day_test = perm[DAY]
          #I keep receiving an attribute error on the line below
  *       if month_test &lt;= 12 and day_test &lt;= monthdays.get(month_test):
              real_outcomes.add(perm)
  
      if len(realOutcomes) &gt; 1:
          return "Ambiguous"
      else:
          return "%02d/%02d/%02d" % realOutcomes.pop()
  </code></pre>