Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.
Write a
Ex: If the input is:
apples 5 shoes 2 quit 0
the output is:
Eating 5 apples a day keeps the doctor away. Eating 2 shoes a day keeps the doctor away.
Note: This is a lab from a previous chapter that now requires the use of a loop.
My code
user_input = input()
while True:
item = user_input.split()[0]
item_count = int(user_input.split()[1])
if item.lower() == "quit":
break
print("Eating " + str(item_count) + " " + item + " a day keeps the doctor away.")
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images
- 10-6. Addition: One common problem when prompting for numerical input occurs when people provide text instead of numbers. When you try to convert the input to an int, you’ll get a ValueError. Write a program that prompts for two numbers. Add them together and print the result. Catch the ValueError if either input value is not a number, and print a friendly error message. Test your program by entering two numbers and then by entering some text instead of a number.arrow_forwardForms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs Yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: Yes Ex: If the input is: 42,000 or 1995! the output is: No Hint: Use a loop and the Character.isDigit() function.arrow_forwardStrings For this homework, we will be creating a simple program that will take in your basic information and then you will output the specifics outlines below. To get FULL credit, you MUST submit the code and the output. INPUT a) Enter your name (first and last): b) Enter your phone number: c) Enter a letter that is in your name: d) Enter a digit that is in your phone number: OUTPUT NAME • • • The length of your name is: The index for the letter 'e' is: The index for the letter 'a' is: • The index for the letter 'q' is: • From c) above, replace that letter with a '2' PHONE NUMBER • The length of your phone number is: • From d) above, replace that digit with a 'X'arrow_forward
- Convert feet into meters: Write a program which reads the number in feet, converts it tometers, and displays the result. One foot is 0.305 meters. One foot is 12 inches.Sample RunEnter the number of feet16.516.5 feet is 5.0325 meters16.5 feet is 198.0 inchesarrow_forwarduse java programingarrow_forwardJava with out string formarrow_forward
- Code in Pythonarrow_forwardString personName is read from input. Output personName left aligned with a width of 6, followed by " Taylor". End with a newline. Ex: If the input is Juno, then the output is: Juno Taylor Use Javaarrow_forwardogramming Languages home-335 LAB Mad Lib-loops Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways Write a program that takes a string and an integer as input and outputs a sentence using the input values as shown in the example below The program repeats until the input string is quit and disregards the integer input that follows Ex If the input is apples 5 shoes 2 quit o the output is Eating 5 apples a day keeps you happy and healthy. Eating 2 shoes a day keeps you happy and healthy. LAB ACTIVITY B 9 3351 LAB Mad Lib-loops 2 #includearrow_forwardString personName is read from input. Output personName left aligned with a width of 6, followed by " Taylor". End with a newline. Ex: If the input is Juno, then the output is: Juno Taylorarrow_forwardMad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways. Write a program that takes a string and an integer as input, and outputs a sentence using the input values as shown in the example below. The program repeats until the input string is quit and disregards the integer input that follows. Ex: If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps the doctor away. Eating 2 shoes a day keeps the doctor away. user_text word = "" while True:user_text = input().split()word = (user_text[0])if word == 'quit':breaknumber = (user_text[1]) print('Eating {} {} a day keeps the doctor away.'.format(number, word))arrow_forwardMad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways. Write a program that takes a string and an integer as input, and outputs a sentence using the input values as shown in the example below. The program repeats until the input string is quit and disregards the integer input that follows. Ex: If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps the doctor away. Eating 2 shoes a day keeps the doctor away.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education