+ 8

Why this code is not valid? Please explain me

https://code.sololearn.com/cE88kyhw8FVc/?ref=app

19th Sep 2020, 6:17 AM
#It's Tony Stark
#It's Tony Stark - avatar
4 odpowiedzi
+ 3
This is because you are using one(=) after if statement but there should be two(==) one(=) equal sign is used to assign the value in a variable in python and to chech if it is equal or not we have to use two(==) equal signs otherwise it will throw an error
20th Sep 2020, 12:33 PM
Tanvir [Inactive]
Tanvir [Inactive] - avatar
+ 2
Copy paste this and compare it with your piece of code. num1 = int(input("Enter the first number:")) op = input("Enter the operation:") num2 = int(input("Enter the second number:")) if op == "+" : sum = num1 + num2 print("summation:", sum) elif op == "-" : sub = num1 - num2 print("subtraction:", sub) elif op == "*" : mul = num1 * num2 print("multiplication:", mul) elif op == "/" : div = num1 / num2 print("division:", div) else: print(" The operator is not valid ")
19th Sep 2020, 6:28 AM
Avinesh
Avinesh - avatar
+ 1
Because the numbers are string U should use int int(input("enter "))
19th Sep 2020, 6:47 PM
Arshia
Arshia - avatar
0
oops, youre using a bad character to end your if statements
19th Sep 2020, 1:54 PM
Jacob
Jacob - avatar