Question

Create a program that keeps telling the user a joke. Consecutive jokes cannot be the same....

Create a program that keeps telling the user a joke. Consecutive jokes cannot be the same. The joke must follow a question and answer format. For example: Computer: "What's the difference between a snowman and a snow-woman?" User: "Idk what?" Computer: "Snow Balls" The program must ask the user if they would like to keep going after each joke. And if the user says no the program should say goodbye and terminate. Otherwise, the program should continue on its next joke. The program should be able to tell a minimum of 20 different jokes. The program should be able to accept more than 3 different responses to the initial joke question, example "Idk what?", "you tell me", "I don't know what?", etc.

COULD YOU FIXMY ERROR . I HAVE SOLVED THIS CODE I JUST NEED TO FIX SOMETHING.(PYTHON PROGRAMMING)

import random randomJokes = [" What did the traffic light say to the car?", "Why was the little strawberry crying?", "What do you call a nosy pepper?", "Why are frogs are so happy?", "How do you befriend a squirrel?", "Have you heard about the corduroy pillow?", "Why did the jaguar eat the tightrope walker?", "What did the big bucket say to the smaller one?", "What did the big bucket say to the smaller one?", "Why do chicken coups always have two doors?", "What did one hat say to the other?", "Why did the lifeguard kick the elephants out of the pool?", " What do you call a pony with a cough?", "What do you do if someone thinks an onion is the only food that can make them cry?", "What do you call a man with no arms or legs wading in a pool?", "What do cows most like to read?","How does a duck buy lipstick?", "What do you call a guy with a rubber toe?", "What did the cop say to his stomach?", "What do you call a snowman on a hot day?", "What do you do with a sick boat?"] answerList = [["Don’t look! I’m about to change."], ["His mom was in a jam."], ["Jalapeño business."], ["They eat whatever bugs them."], ["Just act like a nut."], ["No? Really? It’s making headlines!"], ["It was craving a well-balanced meal."], ["Lookin’ a little pail there."], ["With four, they’d be chicken sedans."], ["You stay here. I’ll go on ahead."], ["They kept dropping their trunks."], ["Throw a coconut at their face."], ["Bob."], ["Cattle-logs."], ["She just puts it on her bill."], ["Roberto."], ["Stop! I’ve got you under a vest!"], ["Puddle."], ["Take is to the doc already."]] index= 0 yesInput = ["yes", "tell me another", "y", "another", "keep em coming", "go", "ok"] noInput = ["no", "stop", "n", "no more", "go away", "bye"] noAnswer = ["Help", "help", "you tell me", "Idk what?", "you tell me", "I don't know what?", "IDK", "idk", "I don't know", "Tell me the answer", "tell me the answer", "I don't know what?", "I don't know what"] go = True go = True while go: rawInput = input("Would you like to hear a Joke") formatedInput = rawInput.lower().strip('\t\n\r') isInputInYesList= formatedInput in yesInput isInputInNoList= formatedInput in noInput if isInputInYesList or isInputInNoList: if isInputInNoList: print("Good Bye!") go = False if isInputInYesList: rawInput = input(randomJokes[index]) formatedInput = rawInput.lower().strip(' \t\n\r') print(answerList[index]) index = index + 1 else: inCorrectInput= True while inCorrectInput: rawInput = input("\nI don't understand what you are telling me. Try again Goodluck!") formatedInput = rawInput.lower().strip(' \t\n\r') isInputInYesList = formatedInput in yesInput isInputInNoList=formatedInput in noInput

0 0
Add a comment Improve this question Transcribed image text
Answer #1

NOTE: I have completed answer for your question. Please check and let me know if you have any queries. I will get back to you within 24 hours. Thanks for your patience.

As per question it is not clear on what is the problem you are asking to fix. But after looking at the problem there is one bug in loop which i fixed and shared the code. If this is not what you are expecting please respond back clearly on what exactly you want?

Code:


#!/usr/local/bin/python3

import random

def main():
   randomJokes = [" What did the traffic light say to the car?", "Why was the little strawberry crying?", "What do you call a nosy pepper?", "Why are frogs are so happy?", "How do you befriend a squirrel?", "Have you heard about the corduroy pillow?", "Why did the jaguar eat the tightrope walker?", "What did the big bucket say to the smaller one?", "What did the big bucket say to the smaller one?", "Why do chicken coups always have two doors?", "What did one hat say to the other?", "Why did the lifeguard kick the elephants out of the pool?", " What do you call a pony with a cough?", "What do you do if someone thinks an onion is the only food that can make them cry?", "What do you call a man with no arms or legs wading in a pool?", "What do cows most like to read?","How does a duck buy lipstick?", "What do you call a guy with a rubber toe?", "What did the cop say to his stomach?", "What do you call a snowman on a hot day?", "What do you do with a sick boat?"]

   answerList = ["Don’t look! I’m about to change.", "His mom was in a jam.", "Jalapeño business.", "They eat whatever bugs them.", "Just act like a nut.", "No? Really? It’s making headlines!", "It was craving a well-balanced meal.", "Lookin’ a little pail there.", "With four, they’d be chicken sedans.", "You stay here. I’ll go on ahead.", "They kept dropping their trunks.", "Throw a coconut at their face.", "Bob.", "Cattle-logs.", "She just puts it on her bill.", "Roberto.", "Stop! I’ve got you under a vest!", "Puddle.", "Take is to the doc already."]

   yesInput = ["yes", "tell me another", "y", "another", "keep em coming", "go", "ok"]
   noInput = ["no", "stop", "n", "no more", "go away", "bye"]
   noAnswer = ["Help", "help", "you tell me", "Idk what?", "you tell me", "I don't know what?", "IDK", "idk", "I don't know", "Tell me the answer", "tell me the answer", "I don't know what?", "I don't know what"]

   index = 0  
   while True:
       rawInput = input("Would you like to hear a Joke? ")
       formatedInput = rawInput.lower().strip('\t\n\r')

       isInputInYesList = formatedInput in yesInput
       isInputInNoList= formatedInput in noInput
  
       if isInputInNoList:
           print("Good Bye!")
           break
       if isInputInYesList:
           rawInput = input(randomJokes[index] + " ")
           formatedInput = rawInput.lower().strip(' \t\n\r')
           print(answerList[index] + " ")
           index += 1
       else:
           inCorrectInput= True
           while inCorrectInput:
               rawInput = input("\nI don't understand what you are telling me. Try again Goodluck! ")
               formatedInput = rawInput.lower().strip('\t\n\r')

               isInputInYesList = formatedInput in yesInput
               isInputInNoList = formatedInput in noInput              

               if isInputInYesList:
                   break
               elif isInputInNoList:
                   return


if __name__=='__main__':
   main()

Code screenshot:
Code output screenshot:

Add a comment
Know the answer?
Add Answer to:
Create a program that keeps telling the user a joke. Consecutive jokes cannot be the same....
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
  • Create a Python program using a list. You are the owner of a cheese shop, "The...

    Create a Python program using a list. You are the owner of a cheese shop, "The Deceased Macaw" and a customer has arrived. Write a program to greet them. You should first ask if the customer is interested in cheddar, if so, then they are given cheddar. Otherwise, you say that you'll find something. If they say that they don't want cheese, you ask them why they are in a cheese shop? In this exercise, valid user responses are "yes"...

  • Create a menu-driven Java application that solves several math problems. The user will select a number,...

    Create a menu-driven Java application that solves several math problems. The user will select a number, and the program will respond with a necessary data. When the user enters option 5, the program will end. Below is sample output for the program: What would you like me to do? 1. Calculate area of a circle? 2. Convert Fahrenheit temperature to Celsius? 3. Convert miles to kilometer? 4. Convert inches to centimeter? 5. Exit program? Please enter your option: 1 Enter...

  • What did the nursing assistant do incorrectly in this phone conversation? Name: 24 Can I te...

    What did the nursing assistant do incorrectly in this phone conversation? Name: 24 Can I te Okay. I 2. W Communication and Cultural Diversity 13. Demonstrate effective communication on the telephone Scenarios Read the following telephone conversations and think about how the nursing assistant could have better presented herself on the phone. Example #1 Making a call from a facility Hi, who's this? Could you get Ms. Crier on the phone, please? I need to talk to her. She's not...

  • I need to write a C++ program using DEV C++ that reads and prints a joke and its punch line from...

    I need to write a C++ program using DEV C++ that reads and prints a joke and its punch line from two different files. The first file contains a joke, but not its punchline. The second file has the punch line as its last line, preceded by “ garbage.” The main function of the program should open the two files and then call twofunctions, passing each one the file it needs. The first function should read and display each line...

  • 24 CW 13. Demonstrate effective com on the telephone Okay. 1 2. W effective communication in...

    24 CW 13. Demonstrate effective com on the telephone Okay. 1 2. W effective communication in ephone conversations and ursing assistant could have Minunication and Cultural Diversity Scenarios Read the following telephone conversa think about how the nursing assistan better presented herself on the phone. Example #1 Making a call from a facility Hi, who's this? Could you get Ms. Crier on the phone, please: need to talk to her. he's not there? Do you know where she is? I...

  • Can you help me to create this program, please? Prompt the user for the user for...

    Can you help me to create this program, please? Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...

  • which is an argument? which is not? a) You shouldn't vote for Senator John McCain in...

    which is an argument? which is not? a) You shouldn't vote for Senator John McCain in the California Republican primary election. Vote for Texas Governor George Bush instead. I heard on a radio ad that McCain has fathered two children out of his marriage, and some say he's a "closet liberal" (a liberal in politics who doesn't like to admit he's a liberal). b) In this country, we need to either make space exploration a national priority or else get...

  • Write a Java application program that plays a number guessing game with the user. In the...

    Write a Java application program that plays a number guessing game with the user. In the starter code that you are given to help you begin the project, you will find the following lines of code: Random generator = args.length == 0 ? new Random() :                    new Random(Integer.parseInt(args[0])); int secret = generator.nextInt(100); You must keep these lines of code in your program. If you delete these lines, or if you change thse lines in any way, then your program...

  • 1 This week I'd like to know how the IDE installation and first mini porgram went...

    1 This week I'd like to know how the IDE installation and first mini porgram went for 12 you. Specifically answer the following for me please: . Did you install Visual Studio 2017 Community and the Techsmith Jing software? Did you have any problem installing either one? . How did your first program go? . What compiler errors did you generate? . If you're a Mac person, what did you decide to do? . How was it making the Jing...

  • "Mrs. Wilkins," Dr. Blake said, "I want to ask you to participate in what we call...

    "Mrs. Wilkins," Dr. Blake said, "I want to ask you to participate in what we call a Phase 1 trial of a new drug called Novamed. The aim of such a trial, it is my duty to tell you, isn't to treat your disease but to help us determine how toxic Novamed is. What we learn may help us figure out how to help other people." "You mean Novamed won't help me"? Mrs. Wilkins asked. "I can't say that it...

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