Home  >  Q&A  >  body text

return' outside function

nums=[1,2,7,0]
target=9

for i in nums:
    for j in nums:
        if i+j==target and nums.index(i)<nums.index(j):
            return [nums.index(i),nums.index(j)]
File "<ipython-input-45-7bae4e6f6d77>", line 7
    return [nums.index(i),nums.index(j)]
SyntaxError: 'return' outside function


高洛峰高洛峰2901 days ago848

reply all(2)I'll reply

  • 三叔

    三叔2016-11-09 10:23:03

    往哪里return啊

    reply
    0
  • 代言

    代言2016-11-09 10:16:48

    都没有定义函数,你却用上了return。。。。。

    reply
    0
  • Cancelreply