0

X is a single number. Essentially I want to check in the list listaa to know if x is less than or equal to any element in listaa. I have,

if x <= listaa.any():
            continue
Mazdak
  • 105,000
  • 18
  • 159
  • 188
Kweweli
  • 327
  • 3
  • 7
  • Lists by themselves don't have an `any()` method. But There is an built-in `any` function that you can use a generator expression to check your condition against all the list items and pass it to the `any()`. Like `any(x <= i for i in listaa)`. – Mazdak Jun 10 '18 at 13:11

1 Answers1

4

Just check if your value is less than or equal to the maximum of your list:

if x <= max(listaa):
    continue

If you wish to use any, you can use a generator expression. It's a built-in function rather than a list method.

if any(x <= i for i in listaa):
    continue
jpp
  • 159,742
  • 34
  • 281
  • 339