1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erma4kov [3.2K]
3 years ago
14

Write the function longest that, given a nonempty list of strings, finds the longest even-length string that ends with ing. It t

akes a list of strings L as input and returns a string. If there are many longest strings, return the first. If there are no such strings, return the empty string (which clearly indicates that no string was found, since a valid string would need to be at least length 3).
Computers and Technology
1 answer:
lorasvet [3.4K]3 years ago
8 0

Answer:

  1. def longest(L):
  2.    for x in L:
  3.        if(len(x) % 2 == 0):
  4.            if(x.endswith("ing")):
  5.                return x  
  6.    return ""
  7. print(longest(["Playing", "Gaming", "Studying"]))

Explanation:

The solution is written in Python 3.

Firstly, create a function longest that takes one parameter L as required by question (Line 1).

In the function, create a for loop to traverse through each string in L and check if the current string length is even (Line 2 - 3). If so, use string endwiths method to check is the current string ended with "ing". If so return the string (Line 4-5).

At last, test the function by passing a list of string and we shall get the output "Gaming".

You might be interested in
Tom wants a way to automatically create ads and simplify campaign management, using his resources and Google's machine learning
borishaifa [10]

Answer:

Account product feed and uploaded assets

Explanation:

Account product feed and uploaded assets are needed to accomplish Tom’s aims of creating ads automatically and simplify campaign management as part of his Smart Shopping campaign. With Smart Shopping campaigns, Tom’s existing product feed and assets are combined with Google’s machine learning to show a variety of ads across networks.

3 0
4 years ago
A(n) ____________________ stores copies of data or programs that are located on the hard drive and that might be needed soon in
Katarina [22]
Https://m.youtube.com/watch?v=d-5dc8CuOvw
6 0
3 years ago
Help easy 50 points!!!!<br> How do i make someone be the brianliest? No crown thing is appering!!!!
IrinaVladis [17]

Answer:

When someone answers your question there should be a button to crown them but it's weird there is no crown showing...

4 0
3 years ago
Read 2 more answers
HELP URGENT
hram777 [196]
You should structure the text first before you search for a relevant picture
7 0
3 years ago
Read 2 more answers
The negotiators past relationship will affect current behavior if the parties
denis-greek [22]

A. if they have been previously competetive

6 0
3 years ago
Other questions:
  • A file that contains program code is called a ____________.
    13·1 answer
  • Which statement most aptly defines the term networking?
    8·1 answer
  • Briefly explain what are JavaScript librairies​
    12·1 answer
  • To enter new code that performs as intended in the place of the old code that produces an error is the goal of
    9·1 answer
  • Two-dimensional random walk (20 points). A two-dimensional random walk simulates the behavior of a particle moving in a grid of
    14·1 answer
  • The best way to safeguard your document is to save it
    11·1 answer
  • You are a developer for a news, entertainment, lifestyle, and fashion website. User traffic has steadily increased month-over-mo
    11·1 answer
  • I need help pls help me
    8·1 answer
  • Write a pseudocode that receives a positive number from the user, and then,
    14·1 answer
  • Display the Approval Form worksheet and create an IF statement in cell B13 to determine if the applicant is eligible for a perso
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!