Problem with Faulty Calculator exercise [Solved] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Problem with Faulty Calculator exercise [Solved]

The program is faulty calculator. In this except three particular calculations rest all calculations should be correct. In this code everything was alright until I wrote the second set of if else statements. My faulty calculator completely got faulty😶 https://code.sololearn.com/cbOlcDLk8S6v/?ref=app

19th Jan 2021, 3:46 AM
∆BH∆Y
∆BH∆Y - avatar
5 Answers
+ 2
Which if...elif block? One that begins from line 8, or one that begins from line 18? What are you doing with if...elif from line 18 anyways?
19th Jan 2021, 3:54 AM
Ipang
+ 3
∆BH∆Y If you are Good debugger then you are a good programmer. You need to read all the error or Exception and solve one by one
19th Jan 2021, 4:16 AM
A͢J
A͢J - avatar
+ 3
Below is a layout for the multiplication aspect of your code. Use it to finish the rest of your code. May I suggest you test aspects of your code as you write it, to prove that each new concept actually works. Your original code is riddled with flaws, so quite difficult to debug. Code calc_type = input() num1 = int(input()) num2 = int(input()) if calc_type == "Multiply" or calc_type == "Multiplication": if (num1 == 45 and num2 == 3) or (num1 == 3 and num2 == 45): print(555) else: print(num1 * num2 )
19th Jan 2021, 6:08 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
try fix ur code indentation..seems like that cause the error another thing, ur code actually will only run multiplication note that if type_calc == 'Multiplication' or 'Multiply' is not same as if type_calc == 'Multiplication' or type_calc=='Multiply' the first one is always true in python
19th Jan 2021, 4:26 AM
durian
durian - avatar
+ 2
Thank you all of you
19th Jan 2021, 4:40 AM
∆BH∆Y
∆BH∆Y - avatar