If any two items in a list is equal to a given number I just subscribed to the daily coding problems and received my first today.

The problem is:


  Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.


This is what I came up with:

def anyequalto(x, y):
    for i in x:
        if y - i in x:
            return True


anyequalto([10, 15, 3, 7], 17)


I was wondering if anyone had any notes or alternatives as I'm very new to Python and programming.
There's a failing case you might have missed.  If the target number is exactly twice the value of one of the entries, then you'll wrongly return true.

Test case:

anyequalto([5], 10)


Besides that, try to think of a better name for the function.  Perhaps contains_pair_totalling() as a start?