How to return a new string with its first and last characters swapped

The solution for “How to return a new string with its first and last characters swapped” can be found here. The following code will assist you in solving the problem.

>>> temp = “abcde”
>>> temp[1:-1]
‘bcd’
>>> temp[-1:] + temp[1:-1] + temp[:1]
‘ebcda’
>>>

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in