Question

The marketing department wants to make your company’s annual report more upbeat! You have agreed to...

The marketing department wants to make your company’s annual report more upbeat! You have agreed to help them by replacing all occurrences of “good” in the report to “fantastic”, and all occurrences of “poor” to “average”.

Your task is to write a Python function lightup(report) that takes the report as a string argument and returns the enhanced report as a string. You must then print the enhanced report outside the function.

If user response is report = Astros are good and Yankees are poor, the above program should print:

Astros are fantastic and Yankees are average
0 0
Add a comment Improve this question Transcribed image text
Answer #1

def lightup(report):    # function to enhance the string report

    words = report.split()  # creating a word list from words of report

    enhanced = []   # empty list to store result

    for word in words:  # append the words in enhanced list

        if word == "good":

            enhanced.append("fantastic")

        elif word == "poor":

            enhanced.append("average")

        else:

            enhanced.append(word)

    return " ".join(enhanced)   # return the enhanced list as a string

# test case

print(lightup("Astros are good and Yankees are poor"))

FOR HELP PLEASE COMMENT.
THANK YOU.

Add a comment
Know the answer?
Add Answer to:
The marketing department wants to make your company’s annual report more upbeat! You have agreed to...
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
  • please use python and provide run result, thank you! click on pic to make it bigger...

    please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...

  • Recursion and Trees Application – Building a Word Index Make sure you have read and understood...

    Recursion and Trees Application – Building a Word Index Make sure you have read and understood ·         lesson modules week 10 and 11 ·         chapters 9 and 10 of our text ·         module - Lab Homework Requirements before submitting this assignment. Hand in only one program, please. Background: In many applications, the composition of a collection of data items changes over time. Not only are new data items added and existing ones removed, but data items may be duplicated. A list data structure...

  • python 11.8 Multiple committees The eventual goal of this assignment is to compute the total number...

    python 11.8 Multiple committees The eventual goal of this assignment is to compute the total number of ways of forming a collection of committees from an academic department of n professors. The first task is to write a function called committee to compute the number of ways of forming a single committee with members from a collection of n people. This is the same as compușing the number of ways of choosing r people out of n to sit at...

  • Your Assignment ·     You are an outside consulting organization who has been retained by the CEO to...

    Your Assignment ·     You are an outside consulting organization who has been retained by the CEO to fix the problems and make sure the mandate is driven throughout the organization. identify what strategic initiatives and changes you will recommend and the tactics to implement those strategies and changes based on this case study New Product Development Process Improvement Case Study Background:          Horizon Giftables, Inc. is a 35-year-old consumer products company that manufactures and distributes home accessory products and décor items through...

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