Python Practice › String Programs › Program 47
First 4 characters
Write a Python program to get the first 4 characters of a string.
Input
"Sqatools"
Output
Sqat
Approach
- Slice
[:4].
Solution
print("Sqatools"[:4])Output
Sqat
Learn the concept
New to this topic? Read the lesson, then come back.