Get a string made of the first and last 2 chars

In this program, we will take a string as input and get a string made of the first and last 2 chars

Steps to solve the program
  1. Take a list as input.
  2. Print the new string made of the first and last 2 characters from the given string using Indexing.
				
					#Input string
string = "Sqatools"

#Printing output
print(string[:2]+string[-2:])
				
			

Output :

				
					Sqls
				
			

get the first 4 characters of a string.

print the mirror image of the string.

Leave a Comment