Search code examples
pythonlistreturn

Python syntax error when returning two lists from function


I want to return two lists from a function as follows:

for index, file in enumerate(files):
    file_path = dir_path + file
    image_listnew, label_listnew = reader.read_gnt_image(file_path))

but I get "SyntaxError: invalid syntax". The function read_gnt_image() returns two lists and worked with a variation of the code I have above, and I can't figure out what's going wrong.


Solution

  • You have an extra parentheses at the end.

    L1, L2 = func() will work if you return two separate strings.