R
R
rekoshets2021-10-31 22:19:37
Python
rekoshets, 2021-10-31 22:19:37

Why does the error pop up: TypeError: '>' not supported between instances of 'str' and 'int?

x = float(input("Введи первое число: "))
y = float(input("Введи второе число: "))
z = input("Какое действие? У нас есть: + - x : ")

def shet(a,b):
  q = a + b
  c = a * b
  h = a / b
  print(str(a) + "+" + str(b) + " = " + str(q));
  print(str(a) + "x" + str(b) + " = " + str(c));
  print(str(a) + ":" + str(b) + " = " + str(h));

if z == str("-"):
  while (str(x) > int(0)):
    print(f'{str(x)}-{str(y)}={x - y}');
    x-=y
    break
else:
  shet(x,y);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2021-10-31
@rekoshets

Because you can't compare strings with numbers. What do you think is bigger letter A or number 3?

D
Denis, 2021-11-01
@Norkotik

So the error says what's wrong ... If you want, you don't want to, but you have to learn English

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question