Why produces an error at operation "-"?

Was created the calculator and when you select the operation " - " and selecting 2 numbers gives an error: name 'c' is not definded. Help, please!)
April 4th 20 at 00:45
2 answers
April 4th 20 at 00:47
Are you trying to use the variable "c", but you forgot something to assign
c = a + b(this is if what == +)
c = a - b(this is if what == -) - aurelia_Daugherty commented on April 4th 20 at 00:50
@brent.Greenfelder, Attach the whole code. Well there is not much I understand

This piece is not clear where can be error - athena_Torp commented on April 4th 20 at 00:53
@ern, Please #Calculator V2
#Modules for Python on the website Colorama Pip

from colorama import init
from colorama import Fore, Back, Style

# use Colorama to make Termcolor work on Windows too
init()

print( Fore.RESET )
print( Back.GREEN )

what = input("What do we do (+, -): ")

print( Back.CYAN )

a = float( input("Enter the first number: ") )
b = float( input("Enter the second number: ") )

print( Back.YELLOW )

if what == "+": - aurelia_Daugherty commented on April 4th 20 at 00:56
@ern, and I got an error running the code in cmd: C:\Python>math2.py Unable to create process using 'C:\Users\VERA\AppData\Local\Programs\Python\Pyth on38-32\python.exe "C:\Python\math2.py" ' - aurelia_Daugherty commented on April 4th 20 at 00:59
April 4th 20 at 00:49
Name is not defined could mean:
1. You haven't created the variable "c"
2. You have created a variable "c" and it was deleted Garbage Collector
3. You have created a variable "c" out-of-scope of this part of the code
4. You are sealed and have created another variable (for example, "s" Latin)
if what == "+":
c = a + b
print("Result:" + str(c))
elif what == "-":
C = a - b
print("Result:" + str(c))
else:
print("you selected the wrong operation!")

P. S
THIS IS NOT THE WHOLE CODE!!! - aurelia_Daugherty commented on April 4th 20 at 00:58
@trace_Deckow63, so what? - aurelia_Daugherty commented on April 4th 20 at 01:01
c = a + b(this is if what == +)
c = a - b(this is if what == -) - aurelia_Daugherty commented on April 4th 20 at 00:52
@brent.Greenfelder, Can a piece of code to see completely? - nigel_Jast87 commented on April 4th 20 at 00:55
There is an assumption that you forgot to translate a and b from strings to numbers int, float. With the + operator it works, but - no.
what type a and b? if there's typo: Russian "s" - Louvenia.Anderson commented on April 4th 20 at 01:04
@Mose_Hickle, a = float( input("Enter the first number: ") )
b = float( input("Enter the second number: ") ) - aurelia_Daugherty commented on April 4th 20 at 01:07
With spaces/tabs in the if condition is everything okay? - Louvenia.Anderson commented on April 4th 20 at 01:10
@Mose_Hickle, seems to be Yes, but there is another problem, I now can't run them...
Gives this:

C:\Python>math2.py
Unable to create process using 'C:\Users\VERA\AppData\Local\Programs\Python\Pyth
on38-32\python.exe "C:\Python\math2.py" ' - aurelia_Daugherty commented on April 4th 20 at 01:13
@brent.Greenfelder, You would be specifically stated in the question about the fact that you can't run the code. - millie_Hirthe commented on April 4th 20 at 01:16
@Darren_Konopelski, is a separate question indicated, all also sitting - solved...) - aurelia_Daugherty commented on April 4th 20 at 01:19
@brent.Greenfelder, You haven't written the first line, and exactly how you run your code! - millie_Hirthe commented on April 4th 20 at 01:22
@brent.Greenfelder, about the fact that the code gne start: check permissions, update Pip, reinstall / update Python - nigel_Jast87 commented on April 4th 20 at 01:25

Find more questions by tags Python