How can we return a list from a Python function?

PythonServer Side ProgrammingProgramming

There are so many ways we can return a list from a python function. One such function is given below.

Example

def retList():
    list = []
    for i in range(0,10):
        list.append(i)
    return list
a = retList()
print a

Output

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

 

raja
Published on 07-Dec-2017 16:30:07
Advertisements