title: Most common character in a string
body: <blockquote>
    <p>Write a function that takes a string consisting of alphabetic
    characters as input argument and returns the most common character.
    Ignore white spaces i.e. Do not count any white space as a character.
    Note that capitalization does not matter here i.e. that a lower case
    character is equal to a upper case character. In case of a tie between
    certain characters return the last character that has the most count</p>
  </blockquote>
  
  <p><strong>This is the updated code</strong></p>
  
  <pre><code>def most_common_character (input_str):
      input_str = input_str.lower()
      new_string = "".join(input_str.split())
      print(new_string)
      length = len(new_string)
      print(length)
      count = 1
      j = 0
      higher_count = 0
      return_character = ""
      for i in range(0, len(new_string)):
          character = new_string[i]
          while (length - 1):
              if (character == new_string[j + 1]):
                  count += 1
              j += 1
              length -= 1    
              if (higher_count &lt; count):
                  higher_count = count
      return (character)     
  
  #Main Program
  input_str = input("Enter a string: ")
  result = most_common_character(input_str)
  print(result)
  </code></pre>
  
  <p>The above is my code. I am getting an error of <code>string index out of bound</code> which I can't understand why. Also the code only checks the occurrence of first character I am confused about how to proceed to the next character and take the maximum count? </p>
  
  <p><strong>The error i get when I run my code:</strong></p>
  
  <pre><code>&gt; Your answer is NOT CORRECT Your code was tested with different inputs.
  &gt; For example when your function is called as shown below:
  &gt; 
  &gt; most_common_character ('The cosmos is infinite')
  &gt; 
  &gt; ############# Your function returns ############# e The returned variable type is: type 'str'
  &gt; 
  &gt; ######### Correct return value should be ######## i The returned variable type is: type 'str'
  &gt; 
  &gt; ####### Output of student print statements ###### thecosmosisinfinite 19
  </code></pre>