How to fix the following code import random def welcome(): text=…
Question Answered step-by-step How to fix the following code import random def welcome(): text=… How to fix the following code import randomdef welcome(): text= “”” Welcome to The Family Fued””” print(text)def main(): categories = [“favorite cities”, “British foods”, “sea creatures”] select = random.randint(0, 2) answers = {} if select == 0: answers = {“NYC” : 35, “PARIS” : 25, “LONDON” : 20, “LA” : 15, “MIAMI” : 5} elif select == 1: answers = {“FISH AND CHIPS” : 35, “CRUMPETS” : 25, “TEA”: 20, “PASTIES”: 15, “SPOTTED DICK”: 5} elif select == 2: answers = {“SHARKS”: 35, “DOLPHINS” : 25, “WHALES”: 20, “JELLYFISH”: 15, “CRABS”: 5} print(“We surveyed 100 people on”, categories[select]) return answersdef guess(answers): print(“You have five guesses and can get a maximum of 100 points, representing the people surveyed.”) num_guesses = 0 points = 0 guessed = [] while num_guesses < 5: print("Total points:", points) guess = raw_input("Guess: ") if guess.upper() in answers and guess.upper() not in guessed: points += answers[guess.upper()] print("You get", answers[guess.upper()], "points.") guessed += [guess.upper()] else: print("X") num_guesses += 1 return points def gameplay(): while True: welcome() answers = survey_results() points = guess(answers) print("You won", points, "points.") again = raw_input("Would you like to play again? Y/N ") if again.upper() == "N": print("Thanks for playing!") breakgameplay() Computer Science Engineering & Technology Python Programming Share QuestionEmailCopy link Comments (0)


