Is this a bug? What is wrong with this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is this a bug? What is wrong with this?

operation = input(''' Please type in the math operation you would like to complete: + for addition - for subtraction * for multiplication / for division ''') number_1 = int(input('Enter your first number: ')) number_2 = int(input('Enter your second number: ')) if operation == '+': print('{} + {} = '.format(number_1, number_2)) print(number_1 + number_2) elif operation == '-': print('{} - {} = '.format(number_1, number_2)) print(number_1 - number_2) elif operation == '*': print('{} * {} = '.format(number_1, number_2)) print(number_1 * number_2) elif operation == '/': print('{} / {} = '.format(number_1, number_2)) print(number_1 / number_2) else: print('You have not typed a valid operator, please run the program again.') # Call calculate() outside of the function calculate()

8th May 2019, 6:01 AM
AceJr
2 Answers
+ 2
The problem is your identation of your code. I tried to tab the seconds print inside if - elif and works as expected https://code.sololearn.com/cwl4GAse1U8D/#py
8th May 2019, 6:29 AM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
0
Thank you very much.........
8th May 2019, 6:30 AM
AceJr