+ 1

Please help me to make mini calculator

first = input("Enter first number :") operator = input("Enter operation (+,-,*,/,%) : ") second = input("Enter second number :") first = int(first) second = int(second) if operator == "+": print(first + second) elif operator == "-": print(first - second) elif operator == "*": print(first * second) elif operator == "/": print(first / second) elif operator == "%": print(first % second) else: print("invalid operation") Please tell me what is wrong with this code series

6th Aug 2022, 1:01 PM
Ayance Miccra
Ayance Miccra - avatar
6 ответов
+ 1
Save code in playground ans share link here.. If this is all same code you are trying then you have identation errors.. and those can be tested only playground.. Remove spaces before opearator and second..
6th Aug 2022, 1:22 PM
Jayakrishna 🇮🇳
+ 1
The second and third line should be at the same indentation level to the first line. Always remember where to indent lines, in conditionals, loops, functions etc. https://code.sololearn.com/cT5BRIbkia21/?ref=app
6th Aug 2022, 1:21 PM
Ipang
+ 1
guys will you tell me what is identation
6th Aug 2022, 3:24 PM
Ayance Miccra
Ayance Miccra - avatar
+ 1
The code link added by @ipang has clear examples about proper identation. It's about adding spaces to form same block of code. . A free line should start at from the left most side.. If you familiar with other languages like c/c++/java, those uses curly braces { } instead. But python uses Identation. Read the code in above link... Hope that clears...
7th Aug 2022, 12:14 PM
Jayakrishna 🇮🇳
+ 1
To make things simpler you could use the eval() function which is built into python Es operation = input("Enter an operation: ") print(eval(operation)) These 2 lines of code will take even more operations and give the complessive result, by making the calculations in the correct order Es. Input: 5+4*2 Output : 13
7th Aug 2022, 2:15 PM
Roys M
0
identation erro, you should avoid unnessary space before statement
8th Aug 2022, 2:44 AM
Lwin Phyoe