Slicing range() function in Python Last Updated : 03 Nov, 2021 Comments Improve Suggest changes Like Article Like Report range() allows users to generate a series of numbers within a given range. Depending on how many arguments the user is passing to the function, the user can decide where that series of numbers will begin and end as well as how big the difference will be between one number and the next.range() takes mainly three arguments. start: integer starting from which the sequence of integers is to be returned stop: integer before which the sequence of integers is to be returned. The range of integers end at stop – 1. step: integer value which determines the increment between each integer in the sequence Note: For more information, refer to Python range() function Example: Python3 # Python Program to # show range() basics # printing a number for i in range(10): print(i, end =" ") print() Output: 0 1 2 3 4 5 6 7 8 9 Slicing Range function In Python, range objects are not iterators but are iterables. So slicing a range() function does not return an iterator but returns an iterable instead. Example: Python3 # Python program to demonstrate # slicing of range function a = range(100) # Slicing range function ans = a[:50] print(ans) Output: range(0, 50) Now our new range 'ans' has numbers from 0 to 50 (50 exclusive). So a generalization for understanding this is a[start : end : the difference between numbers] So doing something like ans = a[10:89:3] will have a range of numbers starting from 10 till 89 with a difference of 3 in between them. Example: Python3 # Python program to demonstrate # slicing of range function a = range(100) # Slicing range function ans = a[10:89:3] print(ans) ans = a[::5] print(ans) Output: range(10, 89, 3) range(0, 100, 5) Comment More infoAdvertise with us Next Article Slicing range() function in Python D dhruvpanwar31 Follow Improve Article Tags : Python Python Programs Computer Science Fundamentals python-basics Practice Tags : python Similar Reads Python | Alternate range slicing in list List slicing is quite common utility in Python, one can easily slice certain elements from a list, but sometimes, we need to perform that task in non-contiguous manner and slice alternate ranges. Let's discuss how this particular problem can be solved. Method #1 : Using list comprehension List compr 6 min read Python | Custom List slicing Sum The problem of slicing a list has been dealt earlier, but sometimes we need to perform the slicing in variable lengths and its summation according to the input given in other list. This problem has its potential application in web development. Letâs discuss certain ways in which this can be done. Me 7 min read Python | K elements Slicing We often come to the situations in which we need to extract initial K elements of list. This particular problem occurs when we need to optimize memory. This has its application in the day-day programming when sometimes we require to get all the lists of similar size. Letâs discuss certain ways in wh 4 min read Python - Reverse Slicing of given string Reverse slicing in Python is a way to access string elements in reverse order using negative steps.Using Slicing ([::-1])Using slicing with [::-1] in Python, we can reverse a string or list. This technique works by specifying a step of -1, which starts at the end of the sequence and moves backward, 1 min read How To Reverse A List In Python Using Slicing In Python, list slicing is a common practice and it is the most used technique for programmers to solve efficient problems. In this article, we will see how we can reverse a list using slicing in Python. Reverse a List Using Slicing in PythonBelow are some of the examples by which we can perform rev 3 min read Like