Python Practice › List Programs › Program 64
Strings of a given length
Write a Python program to extract the strings of a given length.
Input
["Python", "Sqatools", "Practice", "Program", "test", "list"], size 8
Output
['Sqatools', 'Practice']
Approach
- Filter by
len().
Solution
words = ["Python", "Sqatools", "Practice", "Program", "test", "list"]print([w for w in words if len(w) == 8])Output
['Sqatools', 'Practice']
Learn the concept
New to this topic? Read the lesson, then come back.