I am facing a problem with the output function in leetcode. Usually the code I write is in a function and I don't understand how to give an output of a list because the return function doesn't work with a list. And using a print statement doesn't work as 'printing' doesn't go to 'Output' and goes to 'stdout'. Thank you
I tried both printing and returning the list I want as an output. I got a result online but I don't understand the code, can anyone please help me. Thank you.
You can return lists like so:
def foo(x):
# Or (1,2) or [1,["a",2]] etc
return [1,2]
You are trying to return j + 1
; which is not a list
Do you want to return nums
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.