Menu Close

Check whether all the given numbers lies in range of x and y.

You are given n inputs and two numbers x and y. Check whether all the given numbers lies in range of x and y.
(x <= y). If the condition is true print YES else print NO.

Input Format
       First Line has the number of inputs
       Second Line has Starting range
       Third Line has the Ending range
       Then the N number of inputs


N=int(input("Enter the number of inputs: "))
X=int(input("Enter the starting range: "))
Y=int(input("Enter the ending range: "))
A=[]
print("Enter the numbers: ")
for i in range(N):
  d=int(input(''))
  A.append(d)
f=0
for i in range(N):
  if(A[i]>=X and A[i]<=Y):
    f+=1
if f==N:
  print("YES")
else:
  print("NO")

Input:
        Enter the number of inputs: 3
        Enter the starting range: 6
        Enter the ending range: 10
        Enter the numbers:
        8
        7
        9
Output:
       YES


Exec. on linux

Morae!Q!