Created
March 2, 2018 20:24
-
-
Save sbrinkmeyer/d5de8cb00bbdcdd190b2645d8bee66a1 to your computer and use it in GitHub Desktop.
to see if an array has 2 numbers in it that add up to a search number.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numers = [ 2, 5, 8, 9, 13, 6, 22 ] | |
search_numer = 22 | |
def funcyChicken(numberList=None,searchNumber=None): | |
retValue=False | |
temp_list = numberList[:] | |
for x in range(0,len(numberList)-1): | |
print numberList[x] | |
del temp_list[x] | |
other=search_numer-numberList[x] | |
if other in temp_list: | |
retValue=True | |
break | |
temp_list = numberList[:] | |
return retValue | |
return_value = funcyChicken(numers,search_numer) | |
print 'did we find the number where 2 numbers in the array added up to this? : {}'.format(return_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment