Home > Back-end >  line 1, in <module> F,S = list(map(int,input().split())) ValueError: not enough values to unpa
line 1, in <module> F,S = list(map(int,input().split())) ValueError: not enough values to unpa

Time:11-03

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))

CodePudding user response:

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.

  • Related