title: Where attribute does not exist, create an attribute and give it a default value
body: <p>I am learning Python out of a book and have written myself a long quiz/type game which prints a summary at the end. However, the summary looks for attributes that will not always exist depending on what choices have been made by the user.</p>
  
  <p>I have abstracted this into a basic example to show what I am trying to do. Essentially, I just want to run an attribute error check, for every variable that does not have an attribute, create an attribute with a default value of N/A.</p>
  
  <p>In the below example, I would want it to print:</p>
  
  <p>Forename: Joe
  Surname: Bloggs
  Smith Test: N/A
  Test 4: N/A</p>
  
  <p>I created a class called CodeCleaner which I was going to use to set the N/A values, but got very stuck!</p>
  
  <pre><code>class QuestionSet(object):
      next_set = 'first_set'
  
  class ClaimEngine(QuestionSet):
  
      def current_set(self):
          last_set = "blank"
          while_count = int(0)
          quizset = Sets.subsets
          ParentSet = QuestionSet()
          while ParentSet.next_set != last_set and int(while_count)&lt;50:
              quizset[ParentSet.next_set].questioning()
              while_count = while_count+1
  
  class FirstSet(QuestionSet):
  
      def questioning(self):
          self.value1 = raw_input("Forename:\n")
          QuestionSet.next_set = "second_set"
  
  class SecondSet(QuestionSet):
  
      def questioning(self):
          self.value2 = raw_input("Surname:\n")
          if self.value2 == "Smith":
              self.value3 = "He's a Smith!"
              self.value4 = "Test val 4"
              QuestionSet.next_set = "summary"
          else: 
              QuestionSet.next_set = "summary"
  
  class CodeCleaner(QuestionSet):
  
      def questioning(self):
          mapping = Sets() 
          sets = mapping.subsets
          variable_list = {
          [sets['first_set']].value1,
          [sets['second_set']].value2,
          [sets['second_set']].value3,
          [sets['second_set']].value4
          }
          #while key_no &lt; 4:
          #   try:
          #       print variable_list
          #   except AttributeError:
  
  
  class Summary(QuestionSet):
  
      def questioning(self):
          mapping = Sets() 
          sets = mapping.subsets
          print "Forename:",sets['first_set'].value1
          print "Surname:",sets['second_set'].value2
          print "Smith Test:",sets['second_set'].value3
          print "Test 4:",sets['second_set'].value4
          exit(0)
  
  class Sets(object):
          subsets = {
          'first_set': FirstSet(),
          'second_set': SecondSet(),
          'summary': Summary()
          }
  
  run = ClaimEngine()
  run.current_set()
  </code></pre>
  
  <p>I feel quite lazy asking this question, however, I've been wrestling with this for a few days now! Any help would be appreciated.</p>