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 ")

13th Jun 2020, 9:07 AM
SelvaKumar
2 Respostas
+ 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.
13th Jun 2020, 9:27 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
How to develop my problem solving skills??
13th Jun 2020, 10:14 AM
SelvaKumar