title: How to avoid repetitive if statements in python dictionaries
body: <p>I am trying to create a new dictionary out of html form data that was submitted by the user. I end up writing repetitive if statements, checking if xyz key is in the dictionary in the form data. I know this is a quite suboptimal approach though I am not quite sure how to implement this using python.</p>
  
  <p>This is the form data dictionary:</p>
  
  <pre><code>form_data = {
  'urls': ['www.google.com', 'www.bing.com'],
  'useremail': ['my@email.com'],
  'emailfield': ['1'],
  'addressfield': ['1'],
  'addressfield_info':['Company'],
  'addressfield_instruction': ['Please only if the company is a LLC'],
  'phonefield': ['1'],
  'phonefield_instruction': ['please include area code']
  }
  </code></pre>
  
  <p>and I want to create a dictionary that looks like this:</p>
  
  <pre><code>new_dic = {
  'urls': ['www.google.com', 'www.bing.com'],
  'useremail': ['my@email.com'],
  'infofield': [
                {'field': 'email'},
                {'field': 'address', 'info':'Company', 'instruction': 'Please only if the company is a LLC'},
                {'field':'phone', 'instruction': 'please include area code'}
               ]
  }
  </code></pre>
  
  <p>Important note: The 'xyzfield' is mandatory and the 'xyzfield_info' and 'xyzfield_instruction' are both optional. Also: the user can add more fields and create for instance an 'agefield', 'agefield_info' and 'agefield_instruction'.</p>
  
  <p>The problem I have is about how to efficiently check if xyzfield (email, phone, etc) is in the dictionary. If it is in there, check also if any of the optional fields are in there as well. This looks currently something like this:</p>
  
  <pre><code>if 'emailfield' in form_data:
      infofield = {'field': 'email'}
      if 'emailfield_info' in form_data:
           infofield['info'] = form_data['emailfield_info']
      if 'emailfield_instruction' in form_data:
           infofield['instruction'] = form_data['emailfield_instruction']
  
  cleaned_data['infofields'].append(infofield)
  
  ...
  </code></pre>
  
  <p>and I do this for every field, hence I have 4-5 of this. Additional, I will not be able to process any of the fields that the user has created himself since I don't know the name upfront.</p>
  
  <p>Long story short: How can I make this more efficient and dynamic?</p>