Jun-15-2018, 07:31 AM
The problem:
Given a string, return a new string where the first and last chars have been exchanged.
Also is line 5 necessary, if so what does it do?
Given a string, return a new string where the first and last chars have been exchanged.
str='abfdas' def front_back(str): if len(str)<=1: return(str) x=len(str) y=str[x-1]+str[1:x-1]+str[0] return y print(front_back(a)) print(y)Why does print(y) give off the error "name 'y' is not defined?"
Also is line 5 necessary, if so what does it do?