title: Learning Python and trying to get first two letters and last two letters of a string
body: <p>Here's my code:</p>
  
  <pre><code># B. both_ends
  # Given a string s, return a string made of the first 2
  # and the last 2 chars of the original string,
  # so 'spring' yields 'spng'. However, if the string length
  # is less than 2, return instead the empty string.
  def both_ends(s):
    if len(s) &lt;= 2:
      return ""
    else:
      return s[0] + s[1] + s[len(s)-2] + s[len(s-1)]
    # +++your code here+++
    return
  </code></pre>
  
  <p>Unfortunately my program doesn't run. :( I'm sure I'm overlooking something since I'm a newbie with Python.</p>
  
  <p>Here's the error:</p>
  
  <pre><code>&gt; Traceback (most recent call last):
    File "C:\Users\Sergio\Desktop\google-python-exercises\google-python-exercises\basic\string1.py", line 120, in &lt;module&gt;
      main()
    File "C:\Users\Sergio\Desktop\google-python-exercises\google-python-exercises\basic\string1.py", line 97, in main
      test(both_ends('spring'), 'spng')
    File "C:\Users\Sergio\Desktop\google-python-exercises\google-python-exercises\basic\string1.py", line 44, in both_ends
      return s[0] + s[1] + s[len(s)-2] + s[len(s-1)]
  TypeError: unsupported operand type(s) for -: 'str' and 'int'
  </code></pre>
  
  <p>Thanks for the help guys. :D</p>