На языке мне сделать проверку калькулятора: Нужно чтоб он проверял инпуты и говорил ошибку моментально если задано не то что надо(а мне надо чтоб там было какое либо число)

Вот код:

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

print(Fore.BLACK)
print(Back.CYAN)

a = float(input("Enter your first number: "))

if a == str():
exit()

print(Back.CYAN)

b = float(input("Enter your second number: "))

print(Back.GREEN)

what = input( "What will you do(+)? " )

print(Back.MAGENTA)

if what == "+":
c = a+b
print("Answer: " + str(c))

elif what == "-":
c = a-b
print("Answer: " + str(c))

elif what == "*":
c = a*b
print("Answer: " + str(c))

elif what == "/":
c = a/b
print("Answer: " + str(c))

else:
print(Back.RED)
print("Write something from the suggested!")
print("Try again next time.")

print(Style.RESET_ALL)
exit()

vamagic2001 vamagic2001    2   29.03.2021 17:36    0

Другие вопросы по теме Информатика