Answer to Question #102603 in Python for mlk

Question #102603
Write a python function that can finds the following from a given list of strings.
How many word start with “Help”?
How many words contain “lp” in it?
Print the largest string?
Print three smallest strings?
Print a string which contains ‘lo’ and has length of atleast 10
1
Expert's answer
2020-02-11T05:39:15-0500
def that_can_find_the_following(strings):
    help = 0
    lp = 0
    largest = ''
    smallest = strings[0]
    three_smallest = []
    lo = ''
    for i in strings:
        if i[:4] == 'Help':
            help += 1
        if 'lp' in i:
            lp += 1
        if len(i) > len(largest):
            largest = i
        if 'lo' in i and len(lo) > 9:
            lo = i
    for x in range(3):
        for z in strings:
            if len(z) < len(smallest):
                smallest = z
                strings.pop(z)
                three_smallest.append(smallest)
                smallest = strings[0]
    print('Help ' + help)
    print('lp ' + lp)
    print('largest ' + largest)
    print(' 3 smallest ' + three_smallest[0] + three_smallest[1] + three_smallest[2])
    print('lo '+lo)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS