0

i am getting errors about listing i think its because of some inputs have only one integer

i tried seperating them with map split but it didnt work out

Question:

Enter two integers then compare their values.

The first line of the input consist of a single integer number t which determines the number of tests.

In each of next t lines there are two numbers m and n that are separated by a space character. sample input:

Input Format:

5
9 2
-3 -5
5 28
0 0
19 13

sample output:

9  is greater than  2
-3  is greater than  -5
5  is smaller than  28
n is equal m:  0
19  is greater than  13

my code:

n,m = list(map(int,input().split()))
int(n)
int(m)
if n > m:
   print(n+('is greater than'+m))
if m < n:
   print(m+('is smaller than'+n))
if m > n:
    print(m+('is greater than'+n))
if n < m:
    print(n+('is smaller than'+m))
if n == m:
    print(n+('is equal'+m))
Ata Uslu
  • 11
  • 3

1 Answers1

-1

This erros is happening because you try to separate n and m in the first input. However, the first input should be a loop control bariable.

An example of the code would be:

control = int(input("Control variable: "))

for x in range(control):
   n,m = list(map(int, input().split()))

   if n > m:
       print(f'{n} is grater than {m}')
   elif m > n:
       print(f'{m} is grater than {n}')
   else:
       print(f'{n} is equal to {m}')
    
   x += 1

after, you can perform a check if the user actually passed two numbers.

Mateus
  • 64
  • 4
  • oh thank you i made it like this and it worked ``` lang-py t = int(input()) for i in range(t): n, m = input().split() n = int(n) m = int(m) if n > m: print(n, ' is greater than ', m) if n < m: print(n, ' is smaller than ', m) if n == m: print('n is equal m: ', m) ``` – Ata Uslu Nov 02 '22 at 14:41