title: Python 3: Getting TypeError: Slices must be integers... But they are I believe
body: <p>I am trying to write a function called "middle" that takes the middle 3 digits of odd numbers, or the middle 4 digits of even numbers. If the number is less than 5 digits, it just returns the whole number. Here is my work:</p>
  
  <pre><code>def middle(x):
      mystring=str(x)
      length=len(mystring)
      if len(mystring)&lt;=5:
          return(x)
      elif len(mystring)%2==0:
          return (mystring[((length/2)-1):((length/2)+3)])
      else:
          return (mystring[(length//2):((length//2)+3)])
  middle (1234567890)
  </code></pre>
  
  <p>I keep getting "type error: slice indices must be integers or none or have an_index_method" and I don't understand.</p>