0

I am wondering if I can do this, it's for a Reddit bot

submission = next(x for x in memes_submissions if not x.over_18 if not x.stickied)
Dan A
  • 404
  • 1
  • 6
  • 19

1 Answers1

2

Use and or or to combine conditions.

submission = next(x for x in memes_submissions if not x.over_18 and not x.stickied)
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • 2
    They may mean what do multiple `if`s at the end of a comprehension mean. I didn't know this, but apparently you can list multiple `if`s and they're treated as though they're `and`'d. – Carcigenicate Nov 01 '20 at 22:32