Hacker News new | ask | show | jobs
by tuvistavie 1988 days ago
I am not sure I would advocate for this but, from Python 3.8, this is an instance where assignment expressions could allow the first code without duplication.

    first(x * y
          for x in nums
          if (y := 2020 - x) in nums and x != y)
1 comments

I agree, tuvistavie! But my default machine has 3.7 installed, and I didn't want to get too far ahead of readers. Sometime next year I'll go to 3.8, and look forward to using ":="