Click here to Skip to main content
16,022,238 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<pre>Buyer = input("What is your name: ")

print("What type of home do you want to buy in Riverdale, NY?")
print("Types of homes to buy in Riverdale: Single-family house, Multi-family House, Condo")

Type = input("what type of home are you desired to buy? : ")

if Type == "Single Family House" or "single family house":
    print("Congrats! Single Family house found! Median price is $250,000")
    D = input("What is your bid(price) to buy this home: $")
    if D >= str(300000):
        print(Buyer, ", you are eligible to buy a Single-Family house in Riverdale")
        print("Congrats! First Step has been accomplished!")
    elif D == str(250000):
        print(Buyer, "may be eligible, but considering fees and taxes", Buyer, "may have to pay up to 300,000")
        J = input("If you still want to buy this home, put (Yes) or (No) to proceed: ")
        if J == 'Yes' or 'yes':
            print("Congrats! First Step has been accomplished!")
        else: 
            print("Try searching for other homes in Riverdale, NY")
    else: 
        print(Buyer, ", you are uneligible to buy this house")
        
if Type == "Multi-family House" or "multi-family house":
    print("One Multi-Family house has been found! Median price is $700,000")
    A = input("What is your bid(price) to buy this house: $")
    if A >= str(780000):
        print("Buyer, may be eligible to buy a Multi-Family house in Riverdale!")
        print("Congrats! First Step has been accomplished!")
    elif A == str(700000):
        print(Buyer, ", You may be eligible to buy this house but take into consideration fees and taxes", Buyer,". Considering fees and taxes may add price to $780,000")
        G = input("If you want to continue to buying this Multi-Family house, put (Yes) or (No) to proceed: ")
            if G == 'Yes' or 'yes'or 'YES':
            print("Congrats! First step of the application has been accomplished")
        else: 
            print("Consider searching for other homes next time")
            
    else: 
        print(Buyer, ", You unfortunately are uneligible to buy this Multi-Family House in Riverdale due to low price or external factors")

if Type == "Condo" or "condo":   
    print("Off you go! Condo has been found. Minimum price to buy home is $320,000")
    T = input("What is your bid(price) to buy this condo: $")
    if T >= str(370000):
        print(Buyer, ", you may be eligible to buy this Condo")
    elif T == str(320000):
        print(Buyer, ", you may be eligible but considering taxes price may go up to $370,000.", Buyer, "You may want to reconsider your decision")
        H = input("If you still reconsider buying put (Yes) or (No) to confirm: ")
        if H == 'Yes' or 'yes': 
            print("Congrats! First step of the application has been accomplished")
        else:
            print(Buyer, ",If no then try searching for other homes in Riverdale, NY")
            
    else:
        print(Buyer, ", you are uneligible to buy this house")


Python



What I have tried:

This code prints all the choices instead of one. Ex. If I put multi-family house, this gives me back the single-family house, multi-family house, and condo. I was wondering how to fix this issue.
Posted
Updated 27-Jul-24 8:24am
v2

1 solution

No, it doesn't. If I copy and paste your code into an online python interpreter, all I get is an error message:
Error
[?2004l
  File "/home/main.py", line 34
    if Type == Multi-family House or multi-family house:
                            ^^^^^
SyntaxError: invalid syntax
[?2004h
And that makes sense: it expects both Multi-family and House to be variables and has no idea what to do with an instruction like this:
Python
if A = B C
   DoSomething
You probably mean something like this:
Python
if Type == "Multi-family House" or "multi-family house":
But even then, that won't work because it doesn't compare Type against both strings:
Python
if Type == "Single Family House" or Type == "single family house":
will work better.

You should probably think about what happens if the user enters something else as well: a spelling mistake perhaps? I'd be annoyed if I went to all the effort of typing "Single Family house" and it ignored it because of the type case didn't exactly match, or I added a full stop to make "Single Family House."
Consider using a menu system which allows them to type a single character or digit instead. (It'll make your testing easier as well.)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900