Python Practice › String Programs › Program 47

First 4 characters

EasyString Programs · 47 of 106

Write a Python program to get the first 4 characters of a string.

Advertisement
Input
"Sqatools"
Output
Sqat

Approach

  1. Slice [:4].

Solution

Python
print("Sqatools"[:4])
Output
Sqat
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs