0
Is my code is correct... "Given an array of integers, find two numbers such that they add up to a specific target number."
My answer ⏠x = [ 2,7,11,15] target = 9 ask1 = int (input ("Enter the first number :")) ask2 = int (input ("Enter the second number :")) if ask1 + ask2 == target: y = x.index(ask1), x.index(ask2) print (x) else : print (" Doesn't match with answer ")
2 Answers
+ 5
Doesn't it say *find* two numbers? I think you have to implement an algorithm that would iterate through the list and look for potential pairs that when summed, give the target number.
0
How to develop my problem solving skills??