In this example we will show how to exchange the first character of a string with the last character and form a new string.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
str = input("Please input a string: ")
newStr = str[-1] + str[1:-1] + str[0]
print("After exchanging: ", newStr)
Output:
Please input a string: hello
After exchanging: oellh