1
** 如何打印返回索引1,索引2?我尝试不同的方式,但没有打印出来。 **如何打印返回值?
class Solution:
def twoSum(self, nums, target):
nums = [2,7,11,15]
target = 9
hash_map = {}
for index, value in enumerate(nums):
hash_map[value] = index
for index1, value in enumerate(nums):
if target - value in hash_map:
index2 = hash_map[target - value]
if index1 != index2:
return [index1,index2]
有哪些不同的方式,你试过吗?编辑你的问题,并包括这些尝试。 –
请编辑您的问题,以包含您尝试过的[最小,**完整**和可验证示例](http://stackoverflow.com/help/mcve)。 –
如果您遇到问题,请立即添加或保持和平。 –