how to sum two numbers in a list?

后端 未结 7 1778
我寻月下人不归
我寻月下人不归 2021-01-29 09:17

what is the solution of this by python 3 ?

Given an array of integers, return indices of the two numbers such that they add up to a spe

7条回答
  •  孤城傲影
    2021-01-29 09:53

    We can do the following:

    numbers = [2, 7, 11, 15]
    target =9
    for x in numbers:
        for y in numbers:
            if x+y==target:
                print(x,y)
    

提交回复
热议问题