Question

In: Computer Science

What am i doing wrong. I want for the program to run through then when it...

What am i doing wrong. I want for the program to run through then when it gets to "do you want to play again?enter yes or no" if they choose yes I want it to run again if they choose no then end.

def play():
print("Welcome to the Game of Life!")
print("A. Banker")
print("B. Carpenter")
print("C. Farmer")
user_input = input("What is your occupation? ").upper()
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.")
while True:
x = input(" \n Do You want to play again? Enter Yes or No.").upper()
if x == 'Yes':
play()
elif x == 'No':
print("Thank you for playing.")
break;

Solutions

Expert Solution

def play():
    print("Welcome to the Game of Life!")
    print("A. Banker")
    print("B. Carpenter")
    print("C. Farmer")
    user_input = input("What is your occupation? ").upper()
    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.")


# Just make a call to play to run this code
play()
x = input(" \nDo You want to play again? Enter Yes or No.").upper()
while x == "YES":
    if x == 'YES':
        play()
    elif x == 'NO':
        print("Thank you for playing.")
    x = input(" \nDo You want to play again? Enter Yes or No.").upper()


Related Solutions

I just need 3 and 5. I am not sure what I am doing wrong. I...
I just need 3 and 5. I am not sure what I am doing wrong. I get different numbers every time. Superior Markets, Inc., operates three stores in a large metropolitan area. A segmented absorption costing income statement for the company for the last quarter is given below: Superior Markets, Inc. Income Statement For the Quarter Ended September 30 Total North Store South Store East Store Sales $ 4,800,000 $ 960,000 $ 1,920,000 $ 1,920,000 Cost of goods sold 2,640,000...
What am I doing wrong in this titration problem? Calculate the ph at the equivalence point...
What am I doing wrong in this titration problem? Calculate the ph at the equivalence point for the following titration 0.20M HCl versus 0.20M methylamine (CH3NH2). The Ka of methylammonium is 2.3x10^-11. First I have to divide .20M methylamine by 2 (Why?) to get .10M Then, I set up the equilibrium: (2.3 x 10^-11) = x^2 / .10M Since the ka is SO small, I just multiplied .10 with (2.3 x 10^-11) to get 2.3x10^-12, which is wrong. Why is...
This is in Python I am getting an error when I run this program, also I...
This is in Python I am getting an error when I run this program, also I cannot get any output. Please help! #Input Section def main(): name=input("Please enter the customer's name:") age=int(input("Enter age of the customer: ")) number_of_traffic_violations=int(input("Enter the number of traffic violations: ")) if age <=15 and age >= 105: print('Invalid Entry') if number_of_traffic_violations <0: print('Invalid Entry') #Poccessing Section def Insurance(): if age < 25 and number_of_tickets >= 4 and riskCode == 1: insurancePrice = 480 elif age >=...
I am writing a shell program in C++, to run this program I would run it...
I am writing a shell program in C++, to run this program I would run it in terminal like the following: ./a.out "command1" "command2" using the execv function how to execute command 1 and 2 if they are stored in argv[1] and argv[2] of the main function?
Okay, can someone please tell me what I am doing wrong?? I will show the code...
Okay, can someone please tell me what I am doing wrong?? I will show the code I submitted for the assignment. However, according to my instructor I did it incorrectly but I am not understanding why. I will show the instructor's comment after providing my original code for the assignment. Thank you in advance. * * * * * HourlyTest Class * * * * * import java.util.Scanner; public class HourlyTest {    public static void main(String[] args)     {        ...
Can you write this program, but in python, I just wanna see what am I doing...
Can you write this program, but in python, I just wanna see what am I doing wrong. thank you Instructions: The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $10.00 or more and $3.00 otherwise. Three kinds of gasoline are available: regular at $2.89, plus at $3.09, and super at $3.39 per gallon. User Request: Write a program that prints a statement for a customer. Analysis:...
What am I doing wrong in my bootstrap code for R? x<-c(30, 37, 36, 43, 42,...
What am I doing wrong in my bootstrap code for R? x<-c(30, 37, 36, 43, 42, 43, 43, 46, 41, 42) n = 10 x=pnorm(n,mean=40.3,sd=4.6) mu_0=40.3 s.mean=mean(x) s.sd=sd(x);s.sd [1] NA t.sample=(s.mean-mu_0)/(s.sd/sqrt(n)) B=10000 t=c() count.less=0 count.more=0 for(j in 1:B) + { b.smpl = x[sample(1:n, size = n,replace=TRUE)] + ybar.bs = mean(b.smpl) + sd.bs = sd(b.smpl) + t[j] = (ybar.bs - s.mean)/(sd.bs/sqrt(n)) + if(t[j]>=t.sample){ count.more=count.more+1} + if(t[j]<=t.sample){ count.less=count.less+1} + } Error in if (t[j] >= t.sample) { : missing value where TRUE/FALSE...
Can't figure out what I am doing wrong. Please let me know. Sample output: Please enter...
Can't figure out what I am doing wrong. Please let me know. Sample output: Please enter the name of the weather data file: temperatures.txt Tell me about your crew’s preferred temperature for sailing: What is the coldest temperature they can sail in? 60 What is the hottest temperature they can sail in? 80 Month 1: 93.3 percent of days in range. Month 2: 20.0 percent of days in range. Month 3: 58.1 percent of days in range. Month 4: 100.0...
what am I doing wrong here? thank you! #include <iostream> #include <string> using namespace std; class...
what am I doing wrong here? thank you! #include <iostream> #include <string> using namespace std; class DivSales { private:    int quarterSales[4];    static double totalSales; public:    void add(int, int, int, int);    int sales(int);    static double getValue()    {        return totalSales;    };    void DivSales::add(int s1, int s2, int s3, int s4)    {        quarterSales[0] = s1;        quarterSales[1] = s2;        quarterSales[2] = s3;        quarterSales[3] = s4;...
Hi, I am doing up my homework on mathematics and here are some questions. I want...
Hi, I am doing up my homework on mathematics and here are some questions. I want to cross-reference my answers thank you. Decide if the statements below are True or False. Please include some rough workings for me to understand: (1) Mr. Tan borrowed $500,000 from Bank XYZ at 5% annual interest to be repaid monthly over 20 years. The amount that he pays back to XYZ each month is between $3000 to $3500. (2) Continuing from (1): after 15...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT