title: Iterate through each key and it's value, of a function
body: <p>I have a function that I'm trying to loop through, with the purpose of amending those variables with a <code>", "</code> after them.</p>
  
  <pre><code>def create_merge(address, city, state_province, country, postal_code, contact, state):
      for key in locals().keys():
          for value in locals().values():
              print(key, value)
  </code></pre>
  
  <p>This ...kind of works, but not really. While it gives me a proper readout of all values in that def, it only shows <code>state</code> for the key.  I get why, because I'm looping through all values in the first key, before it moves to the second.</p>
  
  <p>What I'd like to have is a loop that would produce, say:</p>
  
  <pre><code>address 123 My Address
  city 
  state_province Illinois
  country USA
  postal_code 12345
  contact McGruff
  state Illinois
  </code></pre>
  
  <p>And this, clearly just first lists the keys, then the values. How do I do one key and one value at a time?</p>
  
  <pre><code>for key in locals().keys():
      print (key)
  for value in locals().values():
      print (value)
  </code></pre>
  
  <p>...<code>print (key, key.values())</code> doesn't work.</p>
  
  <p>Nor </p>
  
  <pre><code>for key in locals().keys():
      print (key, locals().values())
  </code></pre>
  
  <p>I think I'm getting close, but just can't get it!  Thanks for any suggestions/advice.</p>
  
  <p>Final note: I need to do this in a way where I can see if the <code>value</code> is NOT empty, and if not empty, amend the value with <code>", "</code> before the function continues.</p>