+ 1

Y iam getting name error 'c' is not defined when i use - sign and when i use + sign it is giving output your answer is 3 times

num = input("option: +,*,-") a = int(input("enter any number:")) b = int(input("enter any number:")) if num == "+": c = a + b print (" your Answer is",c) if num == "-": c = a - b print("your answer is",c) if num == "*": c = a * b print("your answer is",c)

30th Mar 2020, 3:09 PM
Rishab patyal
Rishab patyal - avatar
1 Odpowiedź
+ 2
indent the print func inside the if stmt..after checking the first statement false,it run the print func,therefore c is undefined or you could just use the print func at very end of ur code
30th Mar 2020, 3:19 PM
durian
durian - avatar