Question

IN PYTHON Add a while loop to this code so that it will replay the Game...

IN PYTHON

Add a while loop to this code so that it will replay the Game of Life. Be sure to ask the user if they want to play again and exit the loop if they say no.

print("Welcome to the Game of Life!")

print("A. Banker")

print("B. Carpenter")

print("C. Farmer")

user_input = input("What is your occupation? ")

if user_input == "A":

    money = 100

elif user_input == "B":

    money = 70

elif user_input == "C":

    money = 50

print("Great! you will start the game with", money, "dollars.")

Homework Answers

Answer #1
choice = "yes"
while(choice.lower()=='yes'):
    print("Welcome to the Game of Life!")
    print("A. Banker")
    print("B. Carpenter")
    print("C. Farmer")
    user_input = input("What is your occupation? ")
    if user_input == "A":
        money = 100
    elif user_input == "B":
        money = 70
    elif user_input == "C":
        money = 50
    print("Great! you will start the game with", money, "dollars.")
    choice = input("Want to play again? (yes/no) ")

Know the answer?
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
Similar Questions
Draw a flowchart based on the Python code below: ch = -1 #Variable declared for taking...
Draw a flowchart based on the Python code below: ch = -1 #Variable declared for taking option entered by the user print("Enter 0 to 5 for following options: ") print("0-> Issue new ticket number.") print("1-> Assign first ticket in queue to counter 1.") print("2-> Assign first ticket in queue to counter 2.") print("3-> Assign first ticket in queue to counter 3.") print("4-> Assign first ticket in queue to counter 4.") print("5-> Quit Program.") tickets = [] #Declaring list to store...
*PYTHON 3 * Coin taking game Game rules a) The game starts with 22 coins in...
*PYTHON 3 * Coin taking game Game rules a) The game starts with 22 coins in a common pool b) The goal of the game is to take the last coin c) Players take turns removing 1, 2, or 3 coins from the pool d) A player cannot take more coins than remain in the pool e) After each turn, the number of coins that remain in the pool is announced f) When the last coin is taken, the winner...
The premise of this project is to make a basic GUI and code for the game...
The premise of this project is to make a basic GUI and code for the game Keno. The specifics of the gui and game are below. Description: In this project you will implement the popular casino and state lottery game, Keno. This is a somewhat simple game to understand and play which should allow you to focus on learning GUI development in JavaFX and trying your hand at event driven programing. Implementation Details: You may add as many classes, data...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
use repl.it intro to C-programing no advance code also put good comment that i can know...
use repl.it intro to C-programing no advance code also put good comment that i can know whats this code use for  thank you use repl.it intro to C-programing no advance code also put good comment that i can know whats this code use for  thank you program for a game of hangman. Store the word to be guessed as individual characters of an array called word. The player must guess the letters belonging to word. If the user enters a valid letter,...
python problem: ( use a loop to read each character from the string and insert into...
python problem: ( use a loop to read each character from the string and insert into the stack) 1. The function main a5.py continually asks the user for a string, and calls isPalindrome to check whether each string is a palindrome. A palindrome is a word or sequence that reads the same backward as forward, e.g., noon, madam or nurses run. 2. Your function must ignore spaces: when the user enters 'nurses run', the function returns True, to indicate that...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21,...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21, all players who are still standing win. But the players that are not standing have already lost. If the Dealer does not go over 21 but stands on say 19 points then all players having points greater than 19 win. All players having points less than 19 lose. All players having points equal to 19 tie. The program should stop asking to hit if...
   Dice Game – Accumulator Pattern and Conditionals (40 pts) IN PYTHON Write a program dicegame.py...
   Dice Game – Accumulator Pattern and Conditionals (40 pts) IN PYTHON Write a program dicegame.py that has the following functions in the following order: in python Write a function roll that takes an int n and returns a random number between 1 and n inclusive. Note: This function represents a n sided die so it should produce pseudo random numbers. You can accomplish this using the random module built into python.         (3 pts) Write a function scoreRound that...
main The main method instantiates an ArrayList object, using the Car class. So, the ArrayList will...
main The main method instantiates an ArrayList object, using the Car class. So, the ArrayList will be filled with Car objects. It will call the displayMenu method to display the menu. Use a sentinel-controlled loop to read the user’s choice from stdin, call the appropriate method based on their choice, and redisplay the menu by calling displayMenu. Be sure to use the most appropriate statement for this type of repetition. displayMenu Parameters:             none Return value:          none Be sure to use...
*********JUST NEED JAVASCRIPT CODE************** I want you to create a Mad Libs game using the information...
*********JUST NEED JAVASCRIPT CODE************** I want you to create a Mad Libs game using the information from the lesson. There are a few requirements. The story must be printed out to the console. You must ask for a minimum of six (6) pieces of information. You must request at least three numbers add a number greater than one to each of them. What you decide to add is up to you but each value must be ADDED (not subtracted) to...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT