Get the first 4 characters of a string

In this program, we will take a string as input and get the first 4 characters of a string.

Steps to solve the program
  1. Take a string as input.
  2. Print the first 4 characters of a string using Indexing.
				
					#Input string
string = "Sqatools"

#Printing output
print(string[:4])
				
			

Output :

				
					Sqat
				
			

words greater than the given length.

get a string made of the first 2 and the last 2 characters

Leave a Comment