Sunday, 20 December 2020

Python: Get list of numbers using range function

We can convert the output of range() function to a list using ‘list()’ function.

 

Example

list(range(1, 10))

>>> list1 = list(range(1, 10))
>>> 
>>> list1
[1, 2, 3, 4, 5, 6, 7, 8, 9]

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment