Q:

Write a Python program to extract specified size of strings from a give list of string values

0

Write a Python program to extract specified size of strings from a give list of string values.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def extract_string(str_list1, l):
    result = [e for e in str_list1 if len(e) == l] 
    return result

str_list1 = ['Python', 'list', 'exercises', 'practice', 'solution'] 
print("Original list:")
print(str_list1)
l = 8
print("\nlength of the string to extract:")
print(l)
print("\nAfter extracting strings of specified length from the said list:") 
print(extract_string(str_list1 , l))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now