Question

using python write a program that will find the longest even word in an array or...

using python

write a program that will find the longest even word in an array or a string. ex: str = "hello", "string", "facebook", "life";

output: facebook

because it's even and the longest in the string

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def longest_even(arr):
    result = ''
    for word in arr:
        if len(word) % 2 == 0 and len(word) > len(result):
            result = word
    return result


def main():
    str = ['hello', 'string', 'facebook', 'life']
    print(longest_even(str))

main()

Process finished with e xit code 0

Add a comment
Know the answer?
Add Answer to:
using python write a program that will find the longest even word in an array or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3. (4 pt) Write a Python program to find the longest common prefix string amongst an...

    3. (4 pt) Write a Python program to find the longest common prefix string amongst an array of strings. You are required to write a function max- Prefix, which when called by the main program would get the array of strings as input and return a single string that would either be the longest 1 common prefix or a string ”NULL” depending on the input. (Note: The array is input from the keyboard in the main program (930)) If there...

  • PYTHON --create a program that accepts a list of words and returns the longest word inside...

    PYTHON --create a program that accepts a list of words and returns the longest word inside that list can only use --- append, len, str, float, range, strip, split, int --create a program that accepts a list of words and a specific length. function will returns a new list that contains the words found with the specific length, and return an empty list if none are found can only use --- append, len, str, float, range, strip, split, int

  • python program- ---create a function that returns the longest word inside a list of words ---create...

    python program- ---create a function that returns the longest word inside a list of words ---create a function with two parameters (phrase,wordList) that returns a count of how many words are spelled incorrectly that cannot be found in wordList (a list of words) for both you can only use these functions --- append, len, str, float, range, strip, split, int.

  • write in python idle Write a full python program that asks the user to type in...

    write in python idle Write a full python program that asks the user to type in 10 words using a loop, prompting the user for each word with a number. The program then displays the longest word and the shortest word the user typed in.

  • 7.13 LAB: Word frequencies (lists) Write a program that first reads in the name of an...

    7.13 LAB: Word frequencies (lists) Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file contains a list of words separated by commas. Your program should output the words and their frequencies (the number of times each word appears in the file) without any duplicates. Ex: If the input is: input1.csv and the contents of input1.csv are: hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy the output is: hello 1 cat 2 man...

  • Write a full python program that asks the user to type in 10 words using a...

    Write a full python program that asks the user to type in 10 words using a loop, prompting the user for each word with a number. The program then displays the longest word and the shortest word the user typed in.

  • This lab will combine reading data from a file and searching the array to find a...

    This lab will combine reading data from a file and searching the array to find a specific value. Assignment Write a program that reads in a file full of strings into an array, and prompts the user for a string to find in the array. The program should loop until a sentinel value (such as -1) is entered. After looping in main() for the input, write a search function, with the following prototype: int findWord(string [], int, string); with arguments...

  • Problem 1: Dynamic Grocery Array Using Java to write a program that prompts the user to...

    Problem 1: Dynamic Grocery Array Using Java to write a program that prompts the user to enter an item’s name for each position in the array. The program then prints uses a loop to output the array. Example 1: Banana 2: Orange 3: Milk 4: Carrot 5: Chips Banana, Orange, Milk, Carrot, Chips Problem 2: Print Characters in String Array    Declare a string array of size 5. Prompt the user enters five strings that are stored in the array....

  • Please help with this python assignment. Thank you. question 1 Write a Python program to read...

    Please help with this python assignment. Thank you. question 1 Write a Python program to read a file line by line store it into a variable. question 2 Write a Python program to read a file line by line store it into an array. question 3 Write a python program to find the longest words. question 4 Write a Python program to count the number of lines in a text file. question 5 Write a Python program to count the...

  • Python Write a program which reads in a string and an signifying the number times the...

    Python Write a program which reads in a string and an signifying the number times the string should be repeated. The program should then output the string N times. integer N, You can assume all input will be valid. Example: Enter a string: hello How many times to repeat? 5 hello hello hello hello hello Example: T Enter a string: goodbye Ty How many times to repeat? 32 goodbye goodbye [... goodbye 30 more times]

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT