title: create a new dictionary by modifying the existing dictionary in python
body: <p>I have a dict as below</p>
  
  <pre><code>querydict = {u'variantcategoryitem_formset_0-0-variant_category_item_price': [u''], u'variantcategoryitem_formset_0-0-variant_category_item_quantity': [u''], u'variantcategoryitem_formset_0-0-variant_category_item_name': [u'hurray'], }
  </code></pre>
  
  <p>So from the above dictionary if it does n't has values for <code>price, quantity</code> fields, i should add the vales as <code>0(quantity), 0.0(price)</code></p>
  
  <p>like below</p>
  
  <pre><code>new_dict = {}
  for key, value in querydict.iteritems():
      # Need to check variant_category_item_qunatity or variant_category_item_price exists in the key, because as u can observe there will be many quantity, price fields in the querydict like variantcategoryitem_formset_0-0-variant_category_item_price, variantcategoryitem_formset_1-1-variant_category_item_price, etc.
  
      if 'variant_category_item_qunatity' in key:
          # If key exists and if equal to ''(empty string) update the new-dict with this key and value as 0(same in case of price below) 
          if not querydict[key]:
              new_dict[key] = 0
      elif 'variant_category_item_price' in key:
          if not querydict[key]:
              new_dict[key] = 0.0
      # Update the entire new_dict with remaining values
      new_dict[key] = value
  </code></pre>
  
  <p>But its not working, i can able to see the dictionary without quantity and price values, so can anyone correct the above logic and create the new dict with the querydict values by updating the price and quantity to 0.0 to 0 if they are <code>''</code> in <code>querydict</code> ?</p>