In this example we will show how to create a new string from the first 3 and last 3 characters of the given string.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
str = input("Please input the string: ")
newStr = str[0:3] + str[-3:]
print("The new string is: ", newStr)
Output:
Please input the string: Hello World
The new string is: Helrld