Home  >  Q&A  >  body text

python - 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
PHP中文网PHP中文网2741 days ago320

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 09:55:24

    There is no function defined, but you use return. . . . .

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:55:24

    Where to return?

    reply
    0
  • Cancelreply