title: Efficiency of dict.get() method
body: <p>I have just started learning python and worried that if I use dict.get(key,default_value) or I define my own method for it....so do they have any differences:</p>
  
  <p>[1st method]:</p>
  
  <pre><code>dict={}
  for c in string:
      if c in dict:
          dict[c]+=1
      else:
          dict[c]=1
  </code></pre>
  
  <p>and the other dict.get() method that python provides</p>
  
  <pre><code>for c in string:
      dict[c]=dict.get(c,0)+1
  </code></pre>
  
  <p>do they have any differences on efficiency or speed...or they are just the same and 2nd one only saves writing few more lines of code...</p>