Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
Python list how to identify the given number is in the range Challenge Question

In python am having the list like

mylist  = [100  30  400 340, 230, 160,  25]

Given number is : 239

My aim is i have to identify this 239(given number) is in the range of or inbetween of the list each lement with +10 and - 10

Example i have to take the first value from list to verify that 243 is in between 100+10 and 100-10 Not that result false

same way have to compare to 30+10 , 30-10 then again 400+10 and 400-10 same like all

if any one of that inbetween the range i have to return as true if not match with any one then return false

How to do that

Here 239 in between 230+10 and 230-10 so no the result i will get as true

How to do this ??

Thank you in avance

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You may iterate on the element of your list, and for each test the expression value-10 < x and x < value+10 that can be written in once in python value-10 < x < value+10

def search_numbers(values, x):
    for value in values:
        if value - 10 < x < value + 10:
            print(f"Ok: {value}-10 < {x} < {value}+10")
            return True
    return False

mylist = [100, 30, 400, 340, 230, 160, 25]
print(search_numbers(mylist, 239))  # True
print(search_numbers(mylist, 243))  # False
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda