title: Python How to specify which character to index if there are duplicates
body: <p>So I am doing an exercise for class where I need to print out which characters occur, and where they occur. I did that with the following code:</p>
  
  <pre><code>def letterInString(string):
     index = 0
     pos = ""
     stringList = list(string)
     positions = []
     counter = 0
     occurences = {}
     for l in string:
         for x in string:
             if x == l:
                 counter += 1
                 positions.append(stringList.index(x))
              for item in positions:
                  if index == 0:
                      pos = str(positions[index])
                      index += 1
                  else:
                      pos = pos + "," + str(positions[index])
                      index += 1
              occurences[l.upper()] = str(counter) + "(" + pos + ")"
              index = 0
              positions = []
          counter = 0
      for key,value in occurences.items():
          print(key + ": " + str(value))
  
  letterInString("hello")
  </code></pre>
  
  <p>The code works just fine for words with no duplicates but when there are duplicates, it doesn't know which letter to index. The last part in my code was just to test certain cases. Please Help!!!</p>
  
  <p>Any help is appreciated!!</p>