Python 3.5 solution for the problem


#1

def solve(self, A):
B = “”;
lt = list(A.split())
if len(lt) == 0:
return B;
for i in range(len(lt) - 1, 0, -1):
B += lt[i] + " "
B += lt[0]
return B