Help me in solving AGELIMIT problem

My issue

How to fix this error, one method could be use of try and except but I am not able to fix this using that also. It would be a great help if anyone could help me fix this.

Traceback (most recent call last):
File “./prog.py”, line 3, in
ValueError: invalid literal for int() with base 10: ‘21 34 30’

My code

t=int(input())
while t>0 :
    x,y,a=int(input())
    if a>=x and a<y :
        print("Yes")
    else:
        print("No")
    t=t-1

Problem Link: AGELIMIT Problem - CodeChef

t=int(input())
while t!=0:
f=input().split(" ")
for i in range (3):
x=f[0]
y=f[1]
a=f[2]
if a>=x and a<y:
print(“YES”)
else:
print(“NO”)
t-=1

‘’’ Consider input as a string, and use the split() function to accept input from single line. Then, break it up’‘’

1 Like

Try this one, It works

#include <iostream>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--){
        int a,x,y;
        cin>>x>>y>>a;
        
        if(a>=x&&a<y)
        cout<<"YES"<<endl;
        
        else
        cout<<"NO"<<endl;
        
    }
	

	return 0;
}

2 Likes

Hey! Have a glance at my code…

def checkEligibility(x, y, a):
if a >= x and a < y:
return “YES”
else:
return “NO”

test = int(input())

for _ in range(test):
x, y, a = map(int, input().split())
result = checkEligibility(x, y, a)
print(result)

1 Like