title: Code in Python that count repeated elements and return the item repeated most times and how many times
body: <p>I have a list with integers, I need to find which item repeat the most, then the function should return two variables (value, number) value is the repeated element and number is the times that repeated</p>
  
  <p>input</p>
  
  <pre><code>B = [1, 5, 1, 3, 5, 1]
  </code></pre>
  
  <p>output</p>
  
  <pre><code>1 3
  </code></pre>
  
  <p>I got a code that works with the first item in the list, but when it goes to the next loop it start everything in zero, so I was struggling to store what I got in the first loop and compare with the second loop to see which one I need to keep.</p>
  
  <p>For this function I am not allowed to use any module or library like "count" or any other advanced code, just as simple as it can be for a rookie level</p>
  
  <pre><code>def counting(B):
     n = len(B)
     tempcount = []
     tempcval = []
  
     for i in range(0,n-1):
        cval=B[i]
        count = 0
  
        for next in B:
           if next == cval:
                count += 1
  
           tempcount.append(count)
           tempcval.append(cval)
  
        return count,cval
  
  def main():
     list = [1, 5, 1, 3, 5, 1]
     a,b = counting(list)
     print(a,b)
  
  main()
  </code></pre>
  
  <p>expected output</p>
  
  <pre><code>3 1
  </code></pre>
  
  <p>actual output</p>
  
  <pre><code>2 5
  </code></pre>