+ 1

Hi,can someone please help me what's wrong with this python code ? I keep getting 1 error.

Hi,can someone please help me what's wrong with this python code ? I keep getting 1 error.Just trying to learn. response_1 = "yes" response_2 = "no" price_of_house = 1000000 buyer_credit = input('Does buyer has good credit? ') buyer_income = input('Does buyer has income of Rs 10000? ') if buyer_credit and buyer_income == response_1: print("Down payment :", (10 * price_of_house/100)) else: print("Down payment :", (20 * price_of_house/100))

5th Sep 2020, 5:49 PM
Sushobhan Sengupta
5 odpowiedzi
+ 1
Steven M's solution is right. The "and" operator will require boolean data type. You can also use " if buyer_credit == buyer_income == response_1:" which check for all of them being of the same value and data type.
5th Sep 2020, 7:04 PM
Emmanuel K
Emmanuel K - avatar
+ 1
There is nothing wrong with your code, I have a feeling it is how you are implementing it into the Playground. Try giving all of your input in the text box. So when you launch your program, there will be an input box, put all of your inputs on separate lines, like this: yes yes Example output: Does buyer has good credit? yes Does buyer has income of Rs 10000? yes Down payment : 100000.0 Does buyer has good credit? yes Does buyer has income of Rs 10000? no Down payment : 200000.0 Does buyer has good credit? no Does buyer has income of Rs 10000? yes Down payment : 100000.0 Does buyer has good credit? no Does buyer has income of Rs 10000? no Down payment : 200000.0
5th Sep 2020, 5:57 PM
Steven M
Steven M - avatar
+ 1
Line 7 I believe should read: if buyer_credit==response_1 and buyer_income==response_1:
5th Sep 2020, 6:16 PM
Steven M
Steven M - avatar
+ 1
Hi, thanks a lot.That solved the problem.
5th Sep 2020, 6:29 PM
Sushobhan Sengupta
0
Hello, thank you for helping out..but I gave a question. shouldn't the third option's output should also be 200000 Does buyer has good credit? no Does buyer has income of Rs 10000? yes Down payment : 100000.0 shouldn't this also be 200000
5th Sep 2020, 6:08 PM
Sushobhan Sengupta