I need to make it so that only numbers can be entered in the input (a and b), and throw an error letters when letters are passed.
Here is my code:
from colorama import init
init()
from colorama import Fore, Back, Style
povt = True
print(Fore.GREEN + "\nMAX-calc")
while povt == True:
what = input(Fore.WHITE + "\nAction " + Fore.GREEN + "(+,-, ×, /): " + Fore.YELLOW)
a = input (Fore.WHITE + "First number: " + Fore.YELLOW)
b = input(Fore.WHITE + "Second number: " + Fore.YELLOW)
psh = input("Enter y: ")
if psh == "y":
if not a:
a=0
if not b:
b=0
if what == "+":
c=float(a)+float(b)
print(Back.YELLOW + Fore.BLACK + "Addition result:" + str(c))
elif what == "-":
c=float(a)-float(b)
print(Back.YELLOW + Fore.BLACK +"Subtraction result:" + str(c))
elif what == "×":
c=float(a)*float(b)
print(Back.YELLOW + Fore.BLACK +"Multiplication result:" + str(c))
elif what == "/":
c=float(a)/float(b)
print(Back.YELLOW + Fore.BLACK +"Division result:" + str(c))
else:
print(Back.RED + Fore.BLACK + "Sorry, I don't know what a " + what + ", is, but I'll try to figure it out > ͜ 0 ")
povto = input("Retry? (y, n): " + Back.BLACK + Fore.YELLOW)
if povto == "n":
povt = False
elif povto == "y":
povt = True
else:
povt = False
print(Back.RED + Fore.BLACK + "OK... we will assume that the " + povto + " - means no > ͜ 0```