First post ever so mods please be nice. Let me know if I need to repost.
Anyways, just getting started with Python, first language other than VBA. I know the solution to this particular exercise. Just curious as to why my particular solution doesn't work. Thank you! Link below.
https://codingbat.com/prob/p153599
Given a string, return a new string where the first and last chars have been exchanged.
front_back('code') → 'eodc'
front_back('a') → 'a'
front_back('ab') → 'ba'
Anyways, just getting started with Python, first language other than VBA. I know the solution to this particular exercise. Just curious as to why my particular solution doesn't work. Thank you! Link below.
https://codingbat.com/prob/p153599
Given a string, return a new string where the first and last chars have been exchanged.
front_back('code') → 'eodc'
front_back('a') → 'a'
front_back('ab') → 'ba'
def front_back(str): first = str[0] last = str[-1] middle = str[1:-2] return last + middle + firstreceiving this error(what does this error mean?): string index out of range