Write a function in Python 2.7 that takes a list of integers as an argument. It should return True or False depending on whether there are any 2 integers in the argument list that sum to zero. [4,-4,9,6,5]





closed as off-topic by Arnauld, dzaima, fəˈnɛtɪk, Pavel, Luis Mendo May 28 '18 at 18:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions without an objective primary winning criterion are off-topic, as they make it impossible to indisputably decide which entry should win." – Arnauld, dzaima, fəˈnɛtɪk, Pavel, Luis Mendo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 9
    \$\begingroup\$ Welcome to PPCG! That's a nice challenge, but unfortunately, we don't like challenges that allow only one language. This challenge is also missing a winning criteria. I'd recommend you to look at few other of challenges there and use our sandbox next time. \$\endgroup\$ – RedClover May 28 '18 at 17:56
  • \$\begingroup\$ I'm guessing this must be code golf as I can't see any other reasonable criteria. (I added the code golf tag, but if that is wrong feel free to specify the correct winning criteria and remove it.) \$\endgroup\$ – Jonathan Allan May 28 '18 at 18:09
  • 6
    \$\begingroup\$ @Arlene what should we return for [0]? \$\endgroup\$ – ngn May 28 '18 at 18:24
  • 3
    \$\begingroup\$ @JonathanAllan Please stop editing programming questions to make them on-topic. Either OP edit the winning criteria in themselves or we close (and optionally someone else repost) it. \$\endgroup\$ – user202729 May 29 '18 at 4:05
  • 1
    \$\begingroup\$ @user202729 I didn't think there was any harm, meta read and noted - it makes sense; thanks \$\endgroup\$ – Jonathan Allan May 29 '18 at 12:41

Python 2, 32 bytes

lambda a:any(-n in a for n in a)

Try it online!


R, 23 bytes


Try it online!

If full programs are allowed:

R, 21 bytes


Try it online!

  • 2
    \$\begingroup\$ Yes any language is fine. Sorry I am new to this. Thank you! \$\endgroup\$ – Arlene May 29 '18 at 22:06
  • \$\begingroup\$ @Arlene Thank you and welcome to PPCG! \$\endgroup\$ – JayCe May 30 '18 at 0:01
  • \$\begingroup\$ @Arlene Please edit your question to reflect the fact that all languages are allowed. Also if you are interested in the shortest solution, I suggest you tag your question code-golf \$\endgroup\$ – JayCe May 30 '18 at 0:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.