I have a list given below as follows
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
How do I return this list or any given list from a python function?
There are so many ways we can return a list from a python function. One such function is given below.
def retList(): list = [] for i in range(0,10): list.append(i) return list a = retList() print a
OUTPUT
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more