64. Problem to extract strings of specified sizes from the list

In this Python list program, we will take a list containing strings as input and extract strings of specified sizes from a given list of string values with the help of the below-given steps.

Extract strings from list:

Steps to solve the program
  1. Take a list containing strings as input.
  2. Create an empty list.
  3. Use a for loop to iterate over strings in the list.
  4. If the length of the strings in the given list is more than the specified number than add those strings to the empty list.
  5. Print the list to see the output.
				
					#Input list
list1 = ["Python", "Sqatools", "Practice", "Program", "test", "lists"]

#Creating an empty string
list2 = []

for string in list1:
    if len(string)>  7:
        list2.append(string)

#Printing output
print(list2)
				
			

Output :

				
					['Sqatools', 'Practice']
				
			

Related Articles

Sort a given list by the sum of sublists

Difference between consecutive numbers in list

Leave a Comment