Answer» Hello. In all honesty, I am asking for help on a homework problem. I've done all that I can on this program, but I still seem to be having trouble. Here is the problem, followed by what I have:
Write a program that declares a different series of lists (lists should not have the same number of words), and ASKS the user how many one-line POEMS she would like to see. In response the program will print that many different poems.
Here is an EXAMPLE of how your program should behave/work (I put in Italics for clarity):
Welcome to the Random Poems of the Day! How many poems would you like me to generate for you? 3
Here are your 3 poems:
Paris Hilton amazingly eats mice in Duckett House every Sunday afternoon The cat never runs on the sofa early in the morning Mrs Christ sometimes runs on the sofa at night
The poems must be centered, with the longest poem starting at the leftmost column. In other words, the longest poem does not have any spaces in front of its first word. - You will need to use the MAX() function, which returns the maximum of a list of numbers.
For this problem, I can't seem to understand how to use the max function to center the poems with the longest poem having no spaces in front of its first word. I do have a code for the poems themselves. Here is what I have: - import random
-
- def main():
- people=["Lil Wayne", "Nicole Richie", "The garbage man", "The Vice-President"]
- verb=["twirls", "shakes", "dances", "yodels", "jumps", "SPITS"]
- adverb=["all the time", "once a week", "ridiculously", "strongly", "frequently"]
- location=["on the hood of the car","behind the stairs", "in front of the principal"]
- time_=["at 1 o'clock in the morning", "at sunrise", "at dinner", "at 8pm", "during brunch"]
-
- poems = [' '.join(random.choice(a) for a in (people, verb, adverb, location, time_))
- for count in range(int(input("How many poems would you like me to generate for you? "))) ]
- print("""
- Welcome to Random Peems of the Day!
-
- Your poems are:
- """)
- print('.\n'.join(poems)+'.')
-
-
- main()
May I please have help with how to use the max function to center the poems with the longest poem having no spaces in front of its first word? I would really appreciate it. Thank you!
|