title: String Duplicate count
body: <p>I am trying to prints counts of a duplicate from an input string through the use of hash map. I am not sure why solution is not working. I come from a python background
  //Write an efficient program to print all the duplicates and their counts in the input string</p>
  <pre><code>func letters(inputs: String)-&gt;[Character:Int] {
      var result = [Character:Int]()
      for input in inputs {
          if let value = result[input] {
              return [input : value]
          }
          else {
              result[input] = (result[input] ?? 0)+1
          }
      }
      return [:]
  }
  letters(inputs:&quot;geeksforgeeks&quot;)
  [&quot;e&quot;: 1]
  </code></pre>